Image compression and decoding, video compression and decoding: methods and systems

ABSTRACT

There is disclosed a computer-implemented method for lossy image or video compression, transmission and decoding, the method including the steps of: (i) receiving an input image at a first computer system; (ii) encoding the input image using a first trained neural network, using the first computer system, to produce a latent representation; (iii) quantizing the latent representation using the first computer system to produce a quantized latent; (iv) entropy encoding the quantized latent into a bitstream, using the first computer system; (v) transmitting the bitstream to a second computer system; (vi) the second computer system entropy decoding the bitstream to produce the quantized latent; (vii) the second computer system using a second trained neural network to produce an output image from the quantized latent, wherein the output image is an approximation of the input image. Related computer-implemented methods, systems, computer-implemented training methods and computer program products are disclosed.

CROSS REFERENCE TO RELATED APPLICATIONS

This is a continuation of U.S. application Ser. No. 18/055,666, filed onNov. 15, 2022, which is a continuation of U.S. application Ser. No.17/740,716, filed on May 10, 2022, which is a continuation ofInternational Application No. PCT/GB2021/051041, filed on Apr. 29, 2021,which claims priority to GB Application No. 2006275.8, filed on Apr. 29,2020; GB Application No. 2008241.8, filed on Jun. 2, 2020; GBApplication No. 2011176.1, filed on Jul. 20, 2020; GB Application No.2012461.6, filed on Aug. 11, 2020; GB Application No. 2012462.4, filedon Aug. 11, 2020; GB Application No. 2012463.2, filed on Aug. 11, 2020;GB Application No. 2012465.7, filed on Aug. 11, 2020; GB Application No.2012467.3, filed on Aug. 11, 2020; GB Application No. 2012468.1, filedon Aug. 11, 2020; GB Application No. 2012469.9, filed on Aug. 11, 2020;GB Application No. 2016824.1, filed on Oct. 23, 2020; GB Application No.2019531.9, filed on Dec. 10, 2020; U.S. Provisional Application No.63/017,295, filed on Apr. 29, 2020; and U.S. Provisional Application No.63/053,807, filed Jul. 20, 2020, the entire contents of each of whichbeing fully incorporated hereby by reference.

BACKGROUND OF THE INVENTION 1. Field of the Invention

The field of the invention relates to computer-implemented methods andsystems for image compression and decoding, to computer-implementedmethods and systems for video compression and decoding, and to relatedcomputer-implemented training methods.

2. Technical Background

There is increasing demand from users of communications networks forimages and video content. Demand is increasing not just for the numberof images viewed, and for the playing time of video; demand is alsoincreasing for higher resolution, lower distortion content, if it can beprovided. This places increasing demand on communications networks, andincreases their energy use, for example, which has adverse costimplications, and possible negative implications for the environment,through the increased energy use.

Although image and video content is usually transmitted overcommunications networks in compressed form, it is desirable to increasethe compression, while preserving displayed image quality, or toincrease the displayed image quality, while not increasing the amount ofdata that is actually transmitted across the communications networks.This would help to reduce the demands on communications networks,compared to the demands that otherwise would be made.

3. Discussion of Related Art

U.S. Ser. No. 10/373,300B1 discloses a system and method for lossy imageand video compression and transmission that utilizes a neural network asa function to map a known noise image to a desired or target image,allowing the transfer only of hyperparameters of the function instead ofa compressed version of the image itself. This allows the recreation ofa high-quality approximation of the desired image by any systemreceiving the hyperparameters, provided that the receiving systempossesses the same noise image and a similar neural network. The amountof data required to transfer an image of a given quality is dramaticallyreduced versus existing image compression technology. Being that videois simply a series of images, the application of this image compressionsystem and method allows the transfer of video content at rates greaterthan previous technologies in relation to the same image quality.

U.S. Ser. No. 10/489,936B1 discloses a system and method for lossy imageand video compression that utilizes a metanetwork to generate a set ofhyperparameters necessary for an image encoding network to reconstructthe desired image from a given noise image.

SUMMARY OF THE INVENTION

According to a first aspect of the invention, there is provided acomputer-implemented method for lossy image or video compression,transmission and decoding, the method including the steps of:

-   -   (i) receiving an input image at a first computer system;    -   (ii) encoding the input image using a first trained neural        network, using the first computer system, to produce a latent        representation;    -   (iii) quantizing the latent representation using the first        computer system to produce a quantized latent;    -   (iv) entropy encoding the quantized latent into a bitstream,        using the first computer system;    -   (v) transmitting the bitstream to a second computer system;    -   (vi) the second computer system entropy decoding the bitstream        to produce the quantized latent;    -   (vii) the second computer system using a second trained neural        network to produce an output image from the quantized latent,        wherein the output image is an approximation of the input image.

An advantage of the invention is that for a fixed file size (“rate”), areduced output image distortion is obtained. An advantage of theinvention is that for a fixed output image distortion, a reduced filesize (“rate”) is obtained.

The method may be one wherein in step (vii) the output image is stored.

The method may be one wherein in step (iii), quantizing the latentrepresentation using the first computer system to produce a quantizedlatent comprises quantizing the latent representation using the firstcomputer system into a discrete set of symbols to produce a quantizedlatent.

The method may be one wherein in step (iv) a predefined probabilitydistribution is used for the entropy encoding and wherein in step (vi)the predefined probability distribution is used for the entropydecoding.

The method may be one wherein in step (iv) parameters characterizing aprobability distribution are calculated, wherein a probabilitydistribution characterised by the parameters is used for the entropyencoding, and wherein in step (iv) the parameters characterizing theprobability distribution are included in the bitstream, and wherein instep (vi) the probability distribution characterised by the parametersis used for the entropy decoding.

The method may be one wherein the probability distribution is a (e.g.factorized) probability distribution.

The method may be one wherein the (e.g. factorized) probabilitydistribution is a (e.g. factorized) normal distribution, and wherein theobtained probability distribution parameters are a respective mean andstandard deviation of each respective element of the quantized y latent.

The method may be one wherein the (e.g. factorized) probabilitydistribution is a parametric (e.g. factorized) probability distribution.

The method may be one wherein the parametric (e.g. factorized)probability distribution is a continuous parametric (e.g. factorized)probability distribution.

The method may be one wherein the parametric (e.g. factorized)probability distribution is a discrete parametric (e.g. factorized)probability distribution.

The method may be one wherein the discrete parametric distribution is aBernoulli distribution, a Rademacher distribution, a binomialdistribution, a beta-binomial distribution, a degenerate distribution atx0, a discrete uniform distribution, a hypergeometric distribution, aPoisson binomial distribution, a Fisher's noncentral hypergeometricdistribution, a Wallenius' noncentral hypergeometric distribution, aBenford's law, an ideal and robust soliton distributions,Conway-Maxwell-Poisson distribution, a Poisson distribution, a Skellamdistribution, a beta negative binomial distribution, a Boltzmanndistribution, a logarithmic (series) distribution, a negative binomialdistribution, a Pascal distribution, a discrete compound Poissondistribution, or a parabolic fractal distribution.

The method may be one wherein parameters included in the parametric(e.g. factorized) probability distribution include shape, asymmetry,skewness and/or any higher moment parameters.

The method may be one wherein the parametric (e.g. factorized)probability distribution is a normal distribution, a Laplacedistribution, a Cauchy distribution, a Logistic distribution, aStudent's t distribution, a Gumbel distribution, an Asymmetric Laplacedistribution, a skew normal distribution, an exponential powerdistribution, a Johnson's SU distribution, a generalized normaldistribution, or a generalized hyperbolic distribution.

The method may be one wherein the parametric (e.g. factorized)probability distribution is a parametric multivariate distribution.

The method may be one wherein the latent space is partitioned intochunks on which intervariable correlations are ascribed; zerocorrelation is prescribed for variables that are far apart and have nomutual influence, wherein the number of parameters required to model thedistribution is reduced, wherein the number of parameters is determinedby the partition size and therefore the extent of the locality.

The method may be one wherein the chunks can be arbitrarily partitionedinto different sizes, shapes and extents.

The method may be one wherein a covariance matrix is used tocharacterise the parametrisation of intervariable dependences.

The method may be one wherein for a continuous probability distributionwith a well-defined PDF, but lacking a well-defined or tractableformulation of its CDF, numerical integration is used through MonteCarlo (MC) or Quasi-Monte Carlo (QMC) based methods, where this canrefer to factorized or to non-factorisable multivariate distributions.

The method may be one wherein a copula is used as a multivariatecumulative distribution function.

The method may be one wherein to obtain a probability density functionover the latent space, the corresponding characteristic function istransformed using a Fourier Transform to obtain the probability densityfunction.

The method may be one wherein to evaluate joint probabilitydistributions over the pixel space, an input of the latent space intothe characteristic function space is transformed, and then thegiven/learned characteristic function is evaluated, and the output isconverted back into the joint-spatial probability space.

The method may be one wherein to incorporate multimodality into entropymodelling, a mixture model is used as a prior distribution.

The method may be one wherein to incorporate multimodality into entropymodelling, a mixture model is used as a prior distribution, comprising aweighted sum of any base (parametric or non-parametric, factorized ornon-factorisable multivariate) distribution as mixture components.

The method may be one wherein the (e.g. factorized) probabilitydistribution is a non-parametric (e.g. factorized) probabilitydistribution.

The method may be one wherein the non-parametric (e.g. factorized)probability distribution is a histogram model, or a kernel densityestimation, or a learned (e.g. factorized) cumulative density function.

The method may be one wherein the probability distribution is anon-factorisable parametric multivariate distribution.

The method may be one wherein a partitioning scheme is applied on avector quantity, such as latent vectors or other arbitrary featurevectors, for the purpose of reducing dimensionality in multivariatemodelling.

The method may be one wherein parametrisation and application ofconsecutive Householder reflections of orthonormal basis matrices isapplied.

The method may be one wherein evaluation of probability mass ofmultivariate normal distributions is performed by analytically computingunivariate conditional parameters from the parametrisation of themultivariate distribution.

The method may be one including use of iterative solvers.

The method may be one including use of iterative solvers to speed upcomputation relating to probabilistic models.

The method may be one wherein the probabilistic models includeautoregressive models.

The method may be one in which an autoregressive model is anIntrapredictions, Neural Intrapredictions and block-level model, or afilter-bank model, or a parameters from Neural Networks model, or aParameters derived from side-information model, or a latent variablesmodel, or a temporal modelling model.

The method may be one wherein the probabilistic models includenon-autoregressive models.

The method may be one in which a non-autoregressive model is aconditional probabilities from an explicit joint distribution model.

The method may be one wherein the joint distribution model is a standardmultivariate distribution model.

The method may be one wherein the joint distribution model is a MarkovRandom Field model.

The method may be one in which a non-autoregressive model is a Genericconditional probability model, or a Dependency network.

The method may be one including use of iterative solvers.

The method may be one including use of iterative solvers to speed upinference speed of neural networks.

The method may be one including use of iterative solvers for fixed pointevaluations.

The method may be one wherein a (e.g. factorized) distribution, in theform of a product of conditional distributions, is used.

The method may be one wherein a system of equations with a triangularstructure is solved using an iterative solver.

The method may be one including use of iterative solvers to decreaseexecution time of the neural networks.

The method may be one including use of context-aware quantisationtechniques by including flexible parameters in the quantisationfunction.

The method may be one including use of dequantisation techniques for thepurpose of assimilating the quantisation residuals through the usage ofcontext modelling or other parametric learnable neural network modules.

The method may be one wherein the first trained neural network is, orincludes, an invertible neural network (INN), and wherein the secondtrained neural network is, or includes, an inverse of the invertibleneural network.

The method may be one wherein there is provided use of FlowGAN, that isan INN-based decoder, and use of a neural encoder, for image or videocompression.

The method may be one wherein normalising flow layers include one ormore of additive coupling layers; multiplicative coupling layers; affinecoupling layers; invertible 1×1 convolution layers.

The method may be one wherein a continuous flow is used.

The method may be one wherein a discrete flow is used.

The method may be one wherein there is provided meta-compression, wherethe decoder weights are compressed with a normalising flow and sentalong within the bitstreams.

The method may be one wherein encoding the input image using the firsttrained neural network includes using one or more univariate ormultivariate Padé activation units.

The method may be one wherein using the second trained neural network toproduce an output image from the quantized latent includes using one ormore univariate or multivariate Padé activation units.

The method may be one wherein steps (ii) to (vii) are executed wholly orpartially in a frequency domain.

The method may be one wherein integral transforms to and from thefrequency domain are used.

The method may be one wherein the integral transforms are FourierTransforms, or Hartley Transforms, or Wavelet Transforms, or ChirpletTransforms, or Sine and Cosine Transforms, or Mellin Transforms, orHankel Transforms, or Laplace Transforms.

The method may be one wherein spectral convolution is used for imagecompression.

The method may be one wherein spectral specific activation functions areused.

The method may be one wherein for downsampling, an input is divided intoseveral blocks that are concatenated in a separate dimension; aconvolution operation with a 1×1 kernel is then applied such that thenumber of channels is reduced by half, and wherein the upsamplingfollows a reverse and mirrored methodology.

The method may be one wherein for image decomposition, stacking isperformed.

The method may be one wherein for image reconstruction, stitching isperformed.

The method may be one wherein a prior distribution is imposed on thelatent space, which is an entropy model, which is optimized over itsassigned parameter space to match its underlying distribution, which inturn lowers encoding computational operations.

The method may be one wherein the parameter space is sufficientlyflexible to properly model the latent distribution.

The method may be one wherein the first computer system is a server,e.g. a dedicated server, e.g a machine in the cloud with dedicated GPUse.g Amazon Web Services, Microsoft Azure, etc, or any other cloudcomputing services.

The method may be one wherein the first computer system is a userdevice.

The method may be one wherein the user device is a laptop computer,desktop computer, a tablet computer or a smart phone.

The method may be one wherein the first trained neural network includesa library installed on the first computer system.

The method may be one wherein the first trained neural network isparametrized by one or several convolution matrices θ, or wherein thefirst trained neural network is parametrized by a set of biasparameters, non-linearity parameters, convolution kernel/matrixparameters.

The method may be one wherein the second computer system is a recipientdevice.

The method may be one wherein the recipient device is a laptop computer,desktop computer, a tablet computer, a smart TV or a smart phone.

The method may be one wherein the second trained neural network includesa library installed on the second computer system.

The method may be one wherein the second trained neural network isparametrized by one or several convolution matrices Ω, or wherein thefirst trained neural network is parametrized by a set of biasparameters, non-linearity parameters, convolution kernel/matrixparameters.

An advantage of the above is that for a fixed file size (“rate”), areduced output image distortion may be obtained. An advantage of theabove is that for a fixed output image distortion, a reduced file size(“rate”) may be obtained.

According to a second aspect of the invention, there is provided asystem for lossy image or video compression, transmission and decoding,the system including a first computer system, a first trained neuralnetwork, a second computer system and a second trained neural network,wherein

-   -   (i) the first computer system is configured to receive an input        image;    -   (ii) the first computer system is configured to encode the input        image using the first trained neural network, to produce a        latent representation;    -   (iii) the first computer system is configured to quantize the        latent representation to produce a quantized latent;    -   (iv) the first computer system is configured to entropy encode        the quantized latent into a bitstream;    -   (v) the first computer system is configured to transmit the        bitstream to the second computer system;    -   (vi) the second computer system is configured to entropy decode        the bitstream to produce the quantized latent;    -   (vii) the second computer system is configured to use the second        trained neural network to produce an output image from the        quantized latent, wherein the output image is an approximation        of the input image.

An advantage of the invention is that for a fixed file size (“rate”), areduced output image distortion is obtained. An advantage of theinvention is that for a fixed output image distortion, a reduced filesize (“rate”) is obtained.

The system may be one wherein the system is configured to perform amethod of any aspect of the first aspect of the invention.

According to a third aspect of the invention, there is provided a firstcomputer system of any aspect of the second aspect of the invention.

According to a fourth aspect of the invention, there is provided asecond computer system of any aspect of the second aspect of theinvention.

According to a fifth aspect of the invention, there is provided acomputer implemented method of training a first neural network and asecond neural network, the neural networks being for use in lossy imageor video compression, transmission and decoding, the method includingthe steps of

-   -   (i) receiving an input training image;    -   (ii) encoding the input training image using the first neural        network, to produce a latent representation;    -   (iii) quantizing the latent representation to produce a        quantized latent;    -   (iv) using the second neural network to produce an output image        from the quantized latent, wherein the output image is an        approximation of the input image;    -   (v) evaluating a loss function based on differences between the        output image and the input training image;    -   (vi) evaluating a gradient of the loss function;    -   (vii) back-propagating the gradient of the loss function through        the second neural network and through the first neural network,        to update weights of the second neural network and of the first        neural network; and    -   (viii) repeating steps (i) to (vii) using a set of training        images, to produce a trained first neural network and a trained        second neural network, and    -   (ix) storing the weights of the trained first neural network and        of the trained second neural network.

An advantage of the invention is that, when using the trained firstneural network and the trained second neural network, for a fixed filesize (“rate”), a reduced output image distortion is obtained; and for afixed output image distortion, a reduced file size (“rate”) is obtained.

The method may be one wherein the loss function is evaluated as aweighted sum of differences between the output image and the inputtraining image, and the estimated bits of the quantized image latents.

The method may be one wherein the steps of the method are performed by acomputer system.

The method may be one wherein the loss function is a weighted sum of arate and a distortion.

The method may be one wherein for differentiability, actual quantisationis replaced by noise quantisation.

The method may be one wherein the noise distribution is uniform,Gaussian or Laplacian distributed, or a Cauchy distribution, a Logisticdistribution, a Student's t distribution, a Gumbel distribution, anAsymmetric Laplace distribution, a skew normal distribution, anexponential power distribution, a Johnson's SU distribution, ageneralized normal distribution, or a generalized hyperbolicdistribution, or any commonly known univariate or multivariatedistribution.

The method may be one including the steps of:

-   -   (iii-a) entropy encoding the quantized latent into a bitstream;    -   (iii-b) entropy decoding the bitstream to produce the quantized        latent.

The method may be one including use of an iterative solving method.

The method may be one in which the iterative solving method is used foran autoregressive model, or for a non-autoregressive model.

The method may be one wherein an automatic differentiation package isused to backpropagate loss gradients through the calculations performedby an iterative solver.

The method may be one wherein another system is solved iteratively forthe gradient.

The method may be one wherein the gradient is approximated and learnedusing a proxy-function, such as a neural network.

The method may be one including using a quantisation proxy.

The method may be one wherein an entropy model of a distribution with anunbiased (constant) rate loss gradient is used for quantisation.

The method may be one including use of a Laplacian entropy model.

The method may be one wherein the twin tower problem is prevented oralleviated, such as by adding a penalty term for latent valuesaccumulating at the positions where the clustering takes place.

The method may be one wherein split quantisation is used for networktraining, with a combination of two quantisation proxies for the rateterm and the distortion term.

The method may be one wherein noise quantisation is used for rate andSTE quantisation is used for distortion.

The method may be one wherein soft-split quantisation is used fornetwork training, with a combination of two quantisation proxies for therate term and for the distortion term.

The method may be one wherein noise quantisation is used for rate andSTE quantisation is used for distortion.

The method may be one wherein either quantisation overrides thegradients of the other.

The method may be one wherein the noise quantisation proxy overrides thegradients for the STE quantisation proxy.

The method may be one wherein QuantNet modules are used, in networktraining for learning a differentiable mapping mimicking truequantisation.

The method may be one wherein learned gradient mappings are used, innetwork training for explicitly learning the backward function of a truequantisation operation.

The method may be one wherein an associated training regime is used, toachieve such a learned mapping, using for instance a simulated annealingapproach or a gradient-based approach.

The method may be one wherein discrete density models are used innetwork training, such as by soft-discretisation of the PDF.

The method may be one wherein context-aware quantisation techniques areused.

The method may be one wherein a parametrisation scheme is used for binwidth parameters.

The method may be one wherein context-aware quantisation techniques areused in a transformed latent space, using bijective mappings.

The method may be one wherein dequantisation techniques are used for thepurpose of modelling continuous probability distributions, usingdiscrete probability models.

The method may be one wherein dequantisation techniques are used for thepurpose of assimilating the quantisation residuals through the usage ofcontext modelling or other parametric learnable neural network modules.

The method may be one including modelling of second-order effects forthe minimisation of quantisation errors.

The method may be one including computing the Hessian matrix of the lossfunction.

The method may be one including using adaptive rounding methods to solvefor the quadratic unconstrained binary optimisation problem posed byminimising the quantisation errors.

The method may be one including maximising mutual information of theinput and output by modelling the difference {circumflex over (x)} minusx as noise, or as a random variable.

The method may be one wherein the input x and the noise are modelled aszero-mean independent Gaussian tensors.

The method may be one wherein the parameters of the mutual informationare learned by neural networks.

The method may be one wherein an aim of the training is to force theencoder-decoder compression pipeline to maximise the mutual informationbetween x and {circumflex over (x)}. The method may be one wherein themethod of training directly maximises mutual information in a one-steptraining process, where the x and noise are fed into respectiveprobability networks S and N, and the mutual information over the entirepipeline is maximised jointly.

The method may be one wherein firstly, the network S and N is trainedusing negative log-likelihood to learn a useful representation ofparameters, and secondly, estimates of the parameters are then used toestimate the mutual information and to train the compression network,however gradients only impact the components within the compressionnetwork; components are trained separately.

The method may be one including maximising mutual information of theinput and output of the compression pipeline by explicitly modelling themutual information using a structured or unstructured bound.

The method may be one wherein the bounds include Barber & Agakov, orInfoNCE, or TUBA, or Nguyen-Wainwright-Jordan (NWJ), or Jensen-Shannon(JS), or TNCE, or BA, or MBU, or Donsker-Varadhan (DV), or IWHVI, orSIVI, or IWAE.

The method may be one including a temporal extension of mutualinformation that conditions the mutual information of the current inputbased on N past inputs.

The method may be one wherein conditioning the joint and the marginalsis used based on N past data points.

The method may be one wherein maximising mutual information of thelatent parameter y and a particular distribution P is a method ofoptimising for rate in the learnt compression pipeline.

The method may be one wherein maximising mutual information of the inputand output is applied to segments of images.

The method may be one wherein encoding the input image using the firstneural network includes using one or more univariate or multivariatePadé activation units.

The method may be one wherein using the second neural network to producean output image from the quantized latent includes using one or moreunivariate or multivariate Padé activation units.

The method may be one wherein when back-propagating the gradient of theloss function through the second neural network and through the firstneural network, parameters of the one or more univariate or multivariatePadé activation units of the first neural network are updated, andparameters of the one or more univariate or multivariate Padé activationunits of the second neural network are updated.

The method may be one wherein in step (ix), the parameters of the one ormore univariate or multivariate Padé activation units of the firstneural network are stored, and the parameters of the one or moreunivariate or multivariate Padé activation units of the second neuralnetwork are stored.

An advantage of the above is that, when using the trained first neuralnetwork and the trained second neural network, for a fixed file size(“rate”), a reduced output image distortion may be obtained; and for afixed output image distortion, a reduced file size (“rate”) may beobtained.

According to a sixth aspect of the invention, there is provided acomputer program product for training a first neural network and asecond neural network, the neural networks being for use in lossy imageor video compression, transmission and decoding, the computer programproduct executable on a processor to:

-   -   (i) receive an input training image;    -   (ii) encode the input training image using the first neural        network, to produce a latent representation;    -   (iii) quantize the latent representation to produce a quantized        latent;    -   (iv) use the second neural network to produce an output image        from the quantized latent, wherein the output image is an        approximation of the input image;    -   (v) evaluate a loss function based on differences between the        output image and the input training image;    -   (vi) evaluate a gradient of the loss function;    -   (vii) back-propagate the gradient of the loss function through        the second neural network and through the first neural network,        to update weights of the second neural network and of the first        neural network; and    -   (viii) repeat (i) to (vii) using a set of training images, to        produce a trained first neural network and a trained second        neural network, and    -   (ix) store the weights of the trained first neural network and        of the trained second neural network.

The computer program product may be one wherein the loss function isevaluated as a weighted sum of differences between the output image andthe input training image, and the estimated bits of the quantized imagelatents.

The computer program product may be executable on the processor toperform a method of any aspect of the fifth aspect of the invention.

According to a seventh aspect of the invention, there is provided acomputer-implemented method for lossy image or video compression,transmission and decoding, the method including the steps of

-   -   (i) receiving an input image at a first computer system;    -   (ii) encoding the input image using a first trained neural        network, using the first computer system, to produce a y latent        representation;    -   (iii) quantizing the y latent representation using the first        computer system to produce a quantized y latent;    -   (iv) encoding the quantized y latent using a third trained        neural network, using the first computer system, to produce a z        latent representation;    -   (v) quantizing the z latent representation using the first        computer system to produce a quantized z latent;    -   (vi) entropy encoding the quantized z latent into a second        bitstream, using the first computer system;    -   (vii) the first computer system processing the quantized z        latent using a fourth trained neural network to obtain        probability distribution parameters of each element of the        quantized y latent, wherein the probability distribution of the        quantized y latent is assumed to be represented by a (e.g.        factorized) probability distribution of each element of the        quantized y latent;    -   (viii) entropy encoding the quantized y latent, using the        obtained probability distribution parameters of each element of        the quantized y latent, into a first bitstream, using the first        computer system;    -   (ix) transmitting the first bitstream and the second bitstream        to a second computer system;    -   (x) the second computer system entropy decoding the second        bitstream to produce the quantized z latent;    -   (xi) the second computer system processing the quantized z        latent using a trained neural network identical to the fourth        trained neural network to obtain the probability distribution        parameters of each element of the quantized y latent;    -   (xii) the second computer system using the obtained probability        distribution parameters of each element of the quantized y        latent, together with the first bitstream, to obtain the        quantized y latent;    -   (xiii) the second computer system using a second trained neural        network to produce an output image from the quantized y latent,        wherein the output image is an approximation of the input image.

An advantage of the invention is that for a fixed file size (“rate”), areduced output image distortion is obtained. An advantage of theinvention is that for a fixed output image distortion, a reduced filesize (“rate”) is obtained.

The method may be one wherein in step (xiii) the output image is stored.

The method may be one wherein in step (iii), quantizing the y latentrepresentation using the first computer system to produce a quantized ylatent comprises quantizing the y latent representation using the firstcomputer system into a discrete set of symbols to produce a quantized ylatent.

The method may be one wherein in step (v), quantizing the z latentrepresentation using the first computer system to produce a quantized zlatent comprises quantizing the z latent representation using the firstcomputer system into a discrete set of symbols to produce a quantized zlatent.

The method may be one wherein in step (vi) a predefined probabilitydistribution is used for the entropy encoding of the quantized z latentand wherein in step (x) the predefined probability distribution is usedfor the entropy decoding to produce the quantized z latent.

The method may be one wherein in step (vi) parameters characterizing aprobability distribution are calculated, wherein a probabilitydistribution characterised by the parameters is used for the entropyencoding of the quantized z latent, and wherein in step (vi) theparameters characterizing the probability distribution are included inthe second bitstream, and wherein in step (x) the probabilitydistribution characterised by the parameters is used for the entropydecoding to produce the quantized z latent.

The method may be one wherein the (e.g. factorized) probabilitydistribution is a (e.g. factorized) normal distribution, and wherein theobtained probability distribution parameters are a respective mean andstandard deviation of each respective element of the quantized y latent.

The method may be one wherein the (e.g. factorized) probabilitydistribution is a parametric (e.g. factorized) probability distribution.

The method may be one wherein the parametric (e.g. factorized)probability distribution is a continuous parametric (e.g. factorized)probability distribution.

The method may be one wherein the parametric (e.g. factorized)probability distribution is a discrete parametric (e.g. factorized)probability distribution.

The method may be one wherein the discrete parametric distribution is aBernoulli distribution, a Rademacher distribution, a binomialdistribution, a beta-binomial distribution, a degenerate distribution atx0, a discrete uniform distribution, a hypergeometric distribution, aPoisson binomial distribution, a Fisher's noncentral hypergeometricdistribution, a Wallenius' noncentral hypergeometric distribution, aBenford's law, an ideal and robust soliton distributions,Conway-Maxwell-Poisson distribution, a Poisson distribution, a Skellamdistribution, a beta negative binomial distribution, a Boltzmanndistribution, a logarithmic (series) distribution, a negative binomialdistribution, a Pascal distribution, a discrete compound Poissondistribution, or a parabolic fractal distribution.

The method may be one wherein parameters included in the parametric(e.g. factorized) probability distribution include shape, asymmetryand/or skewness parameters.

The method may be one wherein the parametric (e.g. factorized)probability distribution is a normal distribution, a Laplacedistribution, a Cauchy distribution, a Logistic distribution, aStudent's t distribution, a Gumbel distribution, an Asymmetric Laplacedistribution, a skew normal distribution, an exponential powerdistribution, a Johnson's SU distribution, a generalized normaldistribution, or a generalized hyperbolic distribution.

The method may be one wherein the parametric (e.g. factorized)probability distribution is a parametric multivariate distribution.

The method may be one wherein the latent space is partitioned intochunks on which intervariable correlations are ascribed; zerocorrelation is prescribed for variables that are far apart and have nomutual influence, wherein the number of parameters required to model thedistribution is reduced, wherein the number of parameters is determinedby the partition size and therefore the extent of the locality.

The method may be one wherein the chunks can be arbitrarily partitionedinto different sizes, shapes and extents.

The method may be one wherein a covariance matrix is used tocharacterise the parametrisation of intervariable dependences.

The method may be one wherein for a continuous probability distributionwith a well-defined PDF, but lacking a well-defined or tractableformulation of its CDF, numerical integration is used through MonteCarlo (MC) or Quasi-Monte Carlo (QMC) based methods, where this canrefer to factorized or to non-factorisable multivariate distributions.

The method may be one wherein a copula is used as a multivariatecumulative distribution function.

The method may be one wherein to obtain a probability density functionover the latent space, the corresponding characteristic function istransformed using a Fourier Transform to obtain the probability densityfunction.

The method may be one wherein to evaluate joint probabilitydistributions over the pixel space, an input of the latent space intothe characteristic function space is transformed, and then thegiven/learned characteristic function is evaluated, and the output isconverted back into the joint-spatial probability space.

The method may be one wherein to incorporate multimodality into entropymodelling, a mixture model is used as a prior distribution.

The method may be one wherein to incorporate multimodality into entropymodelling, a mixture model is used as a prior distribution, comprising aweighted sum of any base (parametric or non-parametric, factorized ornon-factorisable multivariate) distribution as mixture components.

The method may be one wherein the (e.g. factorized) probabilitydistribution is a non-parametric (e.g. factorized) probabilitydistribution.

The method may be one wherein the non-parametric (e.g. factorized)probability distribution is a histogram model, or a kernel densityestimation, or a learned (e.g. factorized) cumulative density function.

The method may be one wherein a prior distribution is imposed on thelatent space, in which the prior distribution is an entropy model, whichis optimized over its assigned parameter space to match its underlyingdistribution, which in turn lowers encoding computational operations.

The method may be one wherein the parameter space is sufficientlyflexible to properly model the latent distribution.

The method may be one wherein encoding the quantized y latent using thethird trained neural network, using the first computer system, toproduce a z latent representation, includes using an invertible neuralnetwork, and wherein the second computer system processing the quantizedz latent to produce the quantized y latent, includes using an inverse ofthe invertible neural network.

The method may be one wherein a hyperprior network of a compressionpipeline is integrated with a normalising flow.

The method may be one wherein there is provided a modification to thearchitecture of normalising flows that introduces hyperprior networks ineach factor-out block.

The method may be one wherein there is provided meta-compression, wherethe decoder weights are compressed with a normalising flow and sentalong within the bitstreams.

The method may be one wherein encoding the input image using the firsttrained neural network includes using one or more univariate ormultivariate Padé activation units.

The method may be one wherein using the second trained neural network toproduce an output image from the quantized latent includes using one ormore univariate or multivariate Padé activation units.

The method may be one wherein encoding the quantized y latent using thethird trained neural network includes using one or more univariate ormultivariate Padé activation units.

The method may be one wherein using the fourth trained neural network toobtain probability distribution parameters of each element of thequantized y latent includes using one or more univariate or multivariatePadé activation units.

The method may be one wherein steps (ii) to (xiii) are executed whollyin a frequency domain.

The method may be one wherein integral transforms to and from thefrequency domain are used.

The method may be one wherein the integral transforms are FourierTransforms, or Hartley Transforms, or Wavelet Transforms, or ChirpletTransforms, or Sine and Cosine Transforms, or Mellin Transforms, orHankel Transforms, or Laplace Transforms.

The method may be one wherein spectral convolution is used for imagecompression.

The method may be one wherein spectral specific activation functions areused.

The method may be one wherein for downsampling, an input is divided intoseveral blocks that are concatenated in a separate dimension; aconvolution operation with a lxi kernel is then applied such that thenumber of channels is reduced by half; and wherein the upsamplingfollows a reverse and mirrored methodology.

The method may be one wherein for image decomposition, stacking isperformed.

The method may be one wherein for image reconstruction, stitching isperformed.

The method may be one wherein the first computer system is a server,e.g. a dedicated server, e.g a machine in the cloud with dedicated GPUse.g Amazon Web Services, Microsoft Azure, etc, or any other cloudcomputing services.

The method may be one wherein the first computer system is a userdevice.

The method may be one wherein the user device is a laptop computer,desktop computer, a tablet computer or a smart phone.

The method may be one wherein the first trained neural network includesa library installed on the first computer system.

The method may be one wherein the first trained neural network isparametrized by one or several convolution matrices θ, or wherein thefirst trained neural network is parametrized by a set of biasparameters, non-linearity parameters, convolution kernel/matrixparameters.

The method may be one wherein the second computer system is a recipientdevice.

The method may be one wherein the recipient device is a laptop computer,desktop computer, a tablet computer, a smart TV or a smart phone.

The method may be one wherein the second trained neural network includesa library installed on the second computer system.

The method may be one wherein the second trained neural network isparametrized by one or several convolution matrices Ω, or wherein thefirst trained neural network is parametrized by a set of biasparameters, non-linearity parameters, convolution kernel/matrixparameters.

An advantage of the above is that for a fixed file size (“rate”), areduced output image distortion may be obtained. An advantage of theabove is that for a fixed output image distortion, a reduced file size(“rate”) may be obtained.

According to an eighth aspect of the invention, there is provided asystem for lossy image or video compression, transmission and decoding,the system including a first computer system, a first trained neuralnetwork, a second computer system, a second trained neural network, athird trained neural network, a fourth trained neural network and atrained neural network identical to the fourth trained neural network,wherein:

-   -   (i) the first computer system is configured to receive an input        image;    -   (ii) the first computer system is configured to encode the input        image using a first trained neural network, to produce a y        latent representation;    -   (iii) the first computer system is configured to quantize the y        latent representation to produce a quantized y latent;    -   (iv) the first computer system is configured to encode the        quantized y latent using a third trained neural network, to        produce a z latent representation;    -   (v) the first computer system is configured to quantize the z        latent representation to produce a quantized z latent;    -   (vi) the first computer system is configured to entropy encode        the quantized z latent into a second bitstream;    -   (vii) the first computer system is configured to process the        quantized z latent using the fourth trained neural network to        obtain probability distribution parameters of each element of        the quantized y latent, wherein the probability distribution of        the quantized y latent is assumed to be represented by a (e.g.        factorized) probability distribution of each element of the        quantized y latent;    -   (viii) the first computer system is configured to entropy encode        the quantized y latent, using the obtained probability        distribution parameters of each element of the quantized y        latent, into a first bitstream;    -   (ix) the first computer system is configured to transmit the        first bitstream and the second bitstream to the second computer        system;    -   (x) the second computer system is configured to entropy decode        the second bitstream to produce the quantized z latent;    -   (xi) the second computer system is configured to process the        quantized z latent using the trained neural network identical to        the fourth trained neural network to obtain the probability        distribution parameters of each element of the quantized y        latent;    -   (xii) the second computer system is configured to use the        obtained probability distribution parameters of each element of        the quantized y latent, together with the first bitstream, to        obtain the quantized y latent;    -   (xiii) the second computer system is configured to use the        second trained neural network to produce an output image from        the quantized y latent, wherein the output image is an        approximation of the input image.

An advantage of the invention is that for a fixed file size (“rate”), areduced output image distortion is obtained. An advantage of theinvention is that for a fixed output image distortion, a reduced filesize (“rate”) is obtained.

The system may be one wherein the system is configured to perform amethod of any aspect of the seventh aspect of the invention.

According to a ninth aspect of the invention, there is provided a firstcomputer system of any aspect of the eighth aspect of the invention.

According to a tenth aspect of the invention, there is provided a secondcomputer system of any aspect of the eighth aspect of the invention.

According to an eleventh aspect of the invention, there is provided acomputer implemented method of training a first neural network, a secondneural network, a third neural network, and a fourth neural network, theneural networks being for use in lossy image or video compression,transmission and decoding, the method including the steps of:

-   -   (i) receiving an input training image;    -   (ii) encoding the input training image using the first neural        network, to produce a y latent representation;    -   (iii) quantizing the y latent representation to produce a        quantized y latent;    -   (iv) encoding the quantized y latent using the third neural        network, to produce a z latent representation;    -   (v) quantizing the z latent representation to produce a        quantized z latent;    -   (vi) processing the quantized z latent using the fourth neural        network to obtain probability distribution parameters of each        element of the quantized y latent, wherein the probability        distribution of the quantized y latent is assumed to be        represented by a (e.g. factorized) probability distribution of        each element of the quantized y latent;    -   (vii) entropy encoding the quantized y latent, using the        obtained probability distribution parameters of each element of        the quantized y latent, into a bitstream;    -   (ix) processing the quantized z latent using the fourth neural        network to obtain the probability distribution parameters of        each element of the quantized y latent;    -   (x) using the obtained probability distribution parameters of        each element of the quantized y latent, together with the        bitstream, to obtain the quantized y latent;    -   (xi) using the second neural network to produce an output image        from the quantized y latent, wherein the output image is an        approximation of the input training image;    -   (xii) evaluating a loss function based on differences between        the output image and the input training image;    -   (xiii) evaluating a gradient of the loss function;    -   (xiv) back-propagating the gradient of the loss function through        the second neural network, through the fourth neural network,        through the third neural network and through the first neural        network, to update weights of the first, second, third and        fourth neural networks; and    -   (xv) repeating steps (i) to (xiv) using a set of training        images, to produce a trained first neural network, a trained        second neural network, a trained third neural network and a        trained fourth neural network, and    -   (xvi) storing the weights of the trained first neural network,        the trained second neural network, the trained third neural        network and the trained fourth neural network.

An advantage of the invention is that, when using the trained firstneural network, the trained second neural network, the trained thirdneural network and the trained fourth neural network, for a fixed filesize (“rate”), a reduced output image distortion is obtained; and for afixed output image distortion, a reduced file size (“rate”) is obtained.

The method may be one wherein the loss function is evaluated as aweighted sum of differences between the output image and the inputtraining image, and the estimated bits of the quantized image latents.

The method may be one wherein the steps of the method are performed by acomputer system.

The method may be one wherein the loss function is a weighted sum of arate and a distortion.

The method may be one wherein for differentiability, actual quantisationis replaced by noise quantisation.

The method may be one wherein the noise distribution is uniform,Gaussian or Laplacian distributed, or a Cauchy distribution, a Logisticdistribution, a Student's t distribution, a Gumbel distribution, anAsymmetric Laplace distribution, a skew normal distribution, anexponential power distribution, a Johnson's SU distribution, ageneralized normal distribution, or a generalized hyperbolicdistribution, or any commonly known univariate or multivariatedistribution.

The method may be one wherein encoding the input training image usingthe first neural network includes using one or more univariate ormultivariate Padé activation units.

The method may be one wherein using the second neural network to producean output image from the quantized y latent includes using one or moreunivariate or multivariate Padé activation units.

The method may be one wherein encoding the quantized y latent using thethird neural network includes using one or more univariate ormultivariate Padé activation units.

The method may be one wherein using the fourth neural network to obtainprobability distribution parameters of each element of the quantized ylatent includes using one or more univariate or multivariate Padéactivation units.

The method may be one wherein when back-propagating the gradient of theloss function through the second neural network, through the fourthneural network, through the third neural network and through the firstneural network, parameters of the one or more univariate or multivariatePadé activation units of the first neural network are updated,parameters of the one or more univariate or multivariate Padé activationunits of the third neural network are updated, parameters of the one ormore univariate or multivariate Padé activation units of the fourthneural network are updated, and parameters of the one or more univariateor multivariate Padé activation units of the second neural network areupdated.

The method may be one wherein in step (ix), the parameters of the one ormore univariate or multivariate Padé activation units of the firstneural network are stored, the parameters of the one or more univariateor multivariate Padé activation units of the second neural network arestored, the parameters of the one or more univariate or multivariatePadé activation units of the third neural network are stored, and theparameters of the one or more univariate or multivariate Padé activationunits of the fourth neural network are stored.

An advantage of the above is that, when using the trained first neuralnetwork, the trained second neural network, the trained third neuralnetwork and the trained fourth neural network, for a fixed file size(“rate”), a reduced output image distortion may be obtained; and for afixed output image distortion, a reduced file size (“rate”) may beobtained.

According to a twelfth aspect of the invention, there is provided acomputer program product for training a first neural network, a secondneural network, a third neural network, and a fourth neural network, theneural networks being for use in lossy image or video compression,transmission and decoding, the computer program product executable on aprocessor to:

-   -   (i) receive an input training image;    -   (ii) encode the input training image using the first neural        network, to produce a y latent representation;    -   (iii) quantize the y latent representation to produce a        quantized y latent;    -   (iv) encode the quantized y latent using the third neural        network, to produce a z latent representation;    -   (v) quantize the z latent representation to produce a quantized        z latent;    -   (vi) processing the quantized z latent using the fourth neural        network to obtain probability distribution parameters of each        element of the quantized y latent, wherein the probability        distribution of the quantized y latent is assumed to be        represented by a (e.g. factorized) probability distribution of        each element of the quantized y latent;    -   (vii) entropy encode the quantized y latent, using the obtained        probability distribution parameters of each element of the        quantized y latent, into a bitstream;    -   (ix) processing the quantized z latent using the fourth neural        network to obtain the probability distribution parameters of        each element of the quantized y latent;    -   (x) process the obtained probability distribution parameters of        each element of the quantized y latent, together with the        bitstream, to obtain the quantized y latent;    -   (xi) use the second neural network to produce an output image        from the quantized y latent, wherein the output image is an        approximation of the input training image;    -   (xii) evaluate a loss function based on differences between the        output image and the input training image;    -   (xiii) evaluate a gradient of the loss function;    -   (xiv) back-propagate the gradient of the loss function through        the second neural network, through the fourth neural network,        through the third neural network and through the first neural        network, to update weights of the first, second, third and        fourth neural networks; and    -   (xv) repeat (i) to (xiv) using a set of training images, to        produce a trained first neural network, a trained second neural        network, a trained third neural network and a trained fourth        neural network, and    -   (xvi) store the weights of the trained first neural network, the        trained second neural network, the trained third neural network        and the trained fourth neural network.

The computer program product may be one wherein the loss function isevaluated as a weighted sum of differences between the output image andthe input training image, and the estimated bits of the quantized imagelatents.

The computer program product may be executable on the processor toperform a method of any aspect of the eleventh aspect of the invention.

According to a thirteenth aspect of the invention, there is provided acomputer-implemented method for lossy image or video compression,transmission and decoding, the method including the steps of

-   -   (i) receiving an input image at a first computer system;    -   (ii) the first computer system segmenting the input image into a        plurality of image segments using a segmentation algorithm;    -   (iii) encoding the image segments using a first trained neural        network, using the first computer system, to produce a latent        representation, wherein the first trained neural network was        trained based on training image segments generated using the        segmentation algorithm;    -   (iv) quantizing the latent representation using the first        computer system to produce a quantized latent;    -   (v) entropy encoding the quantized latent into a bitstream,        using the first computer system;    -   (vi) transmitting the bitstream to a second computer system;    -   (vii) the second computer system entropy decoding the bitstream        to produce the quantized latent;    -   (viii) the second computer system using a second trained neural        network to produce an output image from the quantized latent,        wherein the second trained neural network was trained based on        training image segments generated using the segmentation        algorithm; wherein the output image is an approximation of the        input image.

An advantage of the invention is that for a fixed file size (“rate”), areduced output image distortion is obtained. An advantage of theinvention is that for a fixed output image distortion, a reduced filesize (“rate”) is obtained.

The method may be one wherein in step (viii) the output image is stored.

The method may be one wherein the segmentation algorithm is aclassification-based segmentation algorithm, or an object-basedsegmentation algorithm, or a semantic segmentation algorithm, or aninstance segmentation algorithm, or a clustering based segmentationalgorithm, or a region-based segmentation algorithm, or anedge-detection segmentation algorithm, or a frequency based segmentationalgorithm.

The method may be one wherein the segmentation algorithm is implementedusing a neural network.

The method may be one wherein Just Noticeable Difference (JND) masks areprovided as input into a compression pipeline.

The method may be one wherein JND masks are produced using DiscreteCosine Transform (DCT) and Inverse DCT on the image segments from thesegmentation algorithm.

The method may be one wherein the segmentation algorithm is used in abi-level fashion.

According to a fourteenth aspect of the invention, there is provided acomputer implemented method of training a first neural network and asecond neural network, the neural networks being for use in lossy imageor video compression, transmission and decoding, the method includingthe steps of:

-   -   (i) receiving an input training image;    -   (ii) segmenting the input training image into training image        segments using a segmentation algorithm;    -   (iii) encoding the training image segments using the first        neural network, to produce a latent representation;    -   (iv) quantizing the latent representation to produce a quantized        latent;    -   (v) using the second neural network to produce an output image        from the quantized latent, wherein the output image is an        approximation of the input training image;    -   (vi) evaluating a loss function based on differences between the        output image and the input training image;    -   (vii) evaluating a gradient of the loss function;    -   (viii) back-propagating the gradient of the loss function        through the second neural network and through the first neural        network, to update weights of the second neural network and of        the first neural network; and    -   (ix) repeating steps (i) to (viii) using a set of training        images, to produce a trained first neural network and a trained        second neural network, and    -   (x) storing the weights of the trained first neural network and        of the trained second neural network.

An advantage of the invention is that, when using the trained firstneural network and the trained second neural network, for a fixed filesize (“rate”), a reduced output image distortion is obtained; and for afixed output image distortion, a reduced file size (“rate”) is obtained.

The method may be one wherein the loss function is evaluated as aweighted sum of differences between the output image and the inputtraining image, and the estimated bits of the quantized image latents.

The method may be one wherein the steps of the method are performed by acomputer system.

The method may be one wherein the loss function is a sum of respectiverate and respectively weighted respective distortion, over respectivetraining image segments, of a plurality of training image segments.

The method may be one wherein a higher weight is given to training imagesegments which relate to human faces.

The method may be one wherein a higher weight is given to training imagesegments which relate to text.

The method may be one wherein the segmentation algorithm is implementedusing a neural network.

The method may be one wherein the segmentation algorithm neural networkis trained separately to the first neural network and to the secondneural network.

The method may be one wherein the segmentation algorithm neural networkis trained end-to-end with the first neural network and the secondneural network.

The method may be one wherein gradients from the compression network donot affect the segmentation algorithm neural network training, and thesegmentation network gradients do not affect the compression networkgradients.

The method may be one wherein the training pipeline includes a pluralityof Encoder; Decoder pairs, wherein each Encoder; Decoder pair producespatches with a particular loss function which determines the types ofcompression distortion each compression network produces.

The method may be one wherein the loss function is a sum of respectiverate and respectively weighted respective distortion, over respectivetraining image segments, of a plurality of training image coloursegments.

The method may be one wherein an adversarial GAN loss is applied forhigh frequency regions, and an MSE is applied for low frequency areas.

The method may be one wherein a classifier trained to identify optimaldistortion losses for image or video segments is used to train the firstneural network and the second neural network.

The method may be one wherein the segmentation algorithm is trained in abi-level fashion.

The method may be one wherein the segmentation algorithm is trained in abi-level fashion to selectively apply losses for each segment duringtraining of the first neural network and the second neural network.

An advantage of the above is that, when using the trained first neuralnetwork and the trained second neural network, for a fixed file size(“rate”), a reduced output image distortion may be obtained; and for afixed output image distortion, a reduced file size (“rate”) may beobtained.

According to a fifteenth aspect of the invention, there is provided aclassifier trained to identify optimal distortion losses for image orvideo segments, and usable in a computer implemented method of traininga first neural network and a second neural network of any aspect of thefourteenth aspect of the invention.

According to a sixteenth aspect of the invention, there is provided acomputer-implemented method for training a neural network to predicthuman preferences of compressed image segments for distortion types, themethod including the steps of

-   -   (i) receiving input data comprised of segments of compressed        images along with human preferences for each segment at a        computer system;    -   (ii) the data is sent through the neural network in the computer        system;    -   (iii) a loss is computed based on the human preference        prediction of the neural network and the real human preference        in the data;    -   (iv) the computer system evaluating a gradient of the loss        function;    -   (v) back-propagating the gradient of the loss function through        the neural network, to update weights of the neural network; and    -   (vi) repeating steps (i) to (v) using a set of data, to produce        a trained neural network, and    -   (viii) storing the weights of the trained neural network.

According to a seventeenth aspect of the invention, there is provided acomputer-implemented method for training neural networks for lossy imageor video compression, trained with a segmentation loss with variabledistortion based on estimated human preference, the method including thesteps of

-   -   (i) receiving an input training image at a first computer        system;    -   (ii) the first computer system segmenting the input image into        image segments using a segmentation algorithm;    -   (iii) a second computer system using a second neural network to        estimate human preferences for a set of distortion types for        each image segment;    -   (iv) encoding the training image using the first neural network,        using the first computer system, to produce a latent        representation;    -   (v) quantizing the latent representation using the first        computer system to produce a quantized latent;    -   (vi) a third computer system using a third neural network to        produce an output image from the quantized latent, wherein the        output image is an approximation of the input training image;    -   (vii) the third computer system evaluating an aggregated loss        function, wherein the image distortion is computed for each        segment based on the predicted segment distortion types by the        second neural network;    -   (viii) the third computer system evaluating a gradient of the        loss function;    -   (ix) back-propagating the gradient of the loss function through        the neural network, to update weights of the third neural        network and of the first neural network; and    -   (x) repeating steps (i) to (ix) using a set of training images,        to produce a trained first neural network and a trained third        neural network, and    -   (xi) storing the weights of the trained first neural network and        of the trained third neural network.

The method may be one wherein the loss function is evaluated as aweighted sum of differences between the output image and the inputtraining image, and the estimated bits of the quantized image latents.

According to an eighteenth aspect of the invention, there is provided acomputer implemented method of training a first neural network and asecond neural network based on training images in which each respectivetraining image includes human scored data relating to a perceived levelof distortion in the respective training image as evaluated by a groupof humans, the neural networks being for use in lossy image or videocompression, transmission and decoding, the method including the stepsof:

-   -   (i) receiving an input training image;    -   (ii) encoding the input training image using the first neural        network, to produce a latent representation;    -   (iii) quantizing the latent representation to produce a        quantized latent;    -   (iv) using the second neural network to produce an output image        from the quantized latent, wherein the output image is an        approximation of the input image;    -   (v) evaluating a loss function based on differences between the        output image and the input training image;    -   (vi) evaluating a gradient of the loss function;    -   (vii) back-propagating the gradient of the loss function through        the second neural network and through the first neural network,        to update weights of the second neural network and of the first        neural network; and    -   (viii) repeating steps (i) to (vii) using a set of training        images, to produce a trained first neural network and a trained        second neural network, and    -   (ix) storing the weights of the trained first neural network and        of the trained second neural network;    -   wherein the loss function is a weighted sum of a rate and a        distortion, and wherein the distortion includes the human scored        data of the respective training image.

An advantage of the invention is that, when using the trained firstneural network and the trained second neural network, for a fixed filesize (“rate”), a reduced output image distortion is obtained; and for afixed output image distortion, a reduced file size (“rate”) is obtained.

The method may be one wherein the loss function is evaluated as aweighted sum of differences between the output image and the inputtraining image, and the estimated bits of the quantized image latents.

The method may be one wherein the steps of the method are performed by acomputer system.

The method may be one wherein at least one thousand training images areused.

The method may be one wherein the training images include a wide rangeof distortions.

The method may be one wherein the training images include mainlydistortions introduced using AI-based compression encoder-decoderpipelines.

The method may be one wherein the human scored data is based on humanlabelled data.

The method may be one wherein in step (v) the loss function includes acomponent that represents the human visual system.

According to a nineteenth aspect of the invention, there is provided acomputer-implemented method of learning a function from compressionspecific human labelled image data, the function suitable for use in adistortion function which is suitable for training an AI-basedcompression pipeline for images or video, the method including the stepsof

-   -   (i) passing image data and human labelled image data through a        neural network, wherein the image data and human labelled image        data are combined in the neural network, to output a visual        quality score for the human labelled image data, wherein only        the images are passed through the neural network, and    -   (ii) using a supervised training scheme using standard and        widely known deep learning methods, such as stochastic gradient        decent or back propagation, to train the neural network, wherein        human labelled scores are used in the loss function to provide        the signal to drive the learning.

The method may be one wherein other information (e.g. saliency masks),can be passed into the network along with the images too.

The method may be one wherein rate is used as a proxy to generate andautomatically label data in order to pre-train the neural network.

The method may be one wherein ensemble methods are used to improve therobustness of the neural network.

The method may be one wherein multi-resolution methods are used toimprove the performance of the neural network.

The method may be one wherein Bayesian methods are applied to thelearning process.

The method may be one wherein a learned function is used to train acompression pipeline.

The method may be one wherein a learned function and MSE/PSNR are usedto train a compression pipeline.

According to a twentieth aspect of the invention, there is provided acomputer-implemented method for lossy image or video compression,transmission and decoding, the method including the steps of

-   -   (i) receiving an input pair of stereo images x₁, x₂ at a first        computer system;    -   (ii) encoding the input images using a first trained neural        network, using the first computer system, to produce a latent        representation;    -   (iii) quantizing the latent representation using the first        computer system to produce a quantized latent;    -   (iv) entropy encoding the quantized latent into a bitstream,        using the first computer system;    -   (v) transmitting the bitstream to a second computer system;    -   (vi) the second computer system entropy decoding the bitstream        to produce the quantized latent;    -   (vii) the second computer system using a second trained neural        network to produce an output pair of stereo images {circumflex        over (x)}₁, {circumflex over (x)}₂ from the quantized latent,        wherein the output pair of stereo images {circumflex over (x)}₁,        {circumflex over (x)}₂ is an approximation of the input pair of        stereo images x₁, x₂.

An advantage of the invention is that for a fixed file size (“rate”), areduced output images distortion {circumflex over (x)}₁, {circumflexover (x)}₂ is obtained. An advantage of the invention is that for afixed output images {circumflex over (x)}₁, {circumflex over (x)}₂distortion, a reduced file size (“rate”) is obtained.

The method may be one wherein in step (vii) the output pair of stereoimages is stored.

The method may be one wherein ground-truth dependencies between x₁,{circumflex over (x)}₂ are used as additional input.

The method may be one wherein depth maps of x₁, x₂ are used asadditional input.

The method may be one wherein optical flow data of x₁, x₂ are used asadditional input.

According to a 21st aspect of the invention, there is provided acomputer implemented method of training a first neural network and asecond neural network, the neural networks being for use in lossy imageor video compression, transmission and decoding, the method includingthe steps of

-   -   (i) receiving an input pair of stereo training images x₁, x₂;    -   (ii) encoding the input pair of stereo training images using the        first neural network, to produce a latent representation;    -   (iii) quantizing the latent representation to produce a        quantized latent;    -   (iv) using the second neural network to produce an output pair        of stereo images {circumflex over (x)}₁, {circumflex over (X)}₂        from the quantized latent, wherein the output pair of stereo        images is an approximation of the input images;    -   (v) evaluating a loss function based on differences between the        output pair of stereo images {circumflex over (x)}₁, {circumflex        over (x)}₂ and the input pair of stereo training images x₁, x₂;    -   (vi) evaluating a gradient of the loss function;    -   (vii) back-propagating the gradient of the loss function through        the second neural network and through the first neural network,        to update weights of the second neural network and of the first        neural network; and    -   (viii) repeating steps (i) to (vii) using a set of pairs of        stereo training images, to produce a trained first neural        network and a trained second neural network, and    -   (ix) storing the weights of the trained first neural network and        of the trained second neural network.

An advantage of the invention is that, when using the trained firstneural network and the trained second neural network, for a fixed filesize (“rate”), a reduced output images {circumflex over (x)}₁,{circumflex over (x)}₂ distortion is obtained; and for a fixed outputimages {circumflex over (x)}₁, {circumflex over (x)}₂ distortion, areduced file size (“rate”) is obtained.

The method may be one wherein the loss function is evaluated as aweighted sum of differences between the output images and the inputtraining images, and the estimated bits of the quantized image latents.

The method may be one wherein the steps of the method are performed by acomputer system.

The method may be one wherein the loss function includes using a singleimage depth-map estimation of x₁, x₂, {circumflex over (x)}1,{circumflex over (x)}₂ and then measuring the distortion between thedepths maps of x₁, {circumflex over (x)}₁ and x₂, {circumflex over(x)}₂.

The method may be one wherein the loss function includes using areprojection into the 3-d world using x₁, x₂, and one using {circumflexover (x)}₁, {circumflex over (x)}₂ and a loss measuring the differenceof the resulting 3-d worlds.

The method may be one wherein the loss function includes using opticalflow methods that establish correspondence between pixels in x₁, x₂ and{circumflex over (x)}₁, {circumflex over (x)}₂, and a loss to minimisethese resulting flow-maps.

The method may be one wherein positional location information of thecameras/images and their absolute/relative configuration are encoded inthe neural networks as a prior through the training process.

According to a 22nd aspect of the invention, there is provided acomputer-implemented method for lossy image or video compression,transmission and decoding, the method including the steps of

-   -   (i) receiving N multi-view input images at a first computer        system;    -   (ii) encoding the N multi-view input images using a first        trained neural network, using the first computer system, to        produce a latent representation;    -   (iii) quantizing the latent representation using the first        computer system to produce a quantized latent;    -   (iv) entropy encoding the quantized latent into a bitstream,        using the first computer system;    -   (v) transmitting the bitstream to a second computer system;    -   (vi) the second computer system entropy decoding the bitstream        to produce the quantized latent;    -   (vii) the second computer system using a second trained neural        network to produce N multi-view output images from the quantized        latent, wherein the N multi-view output images are an        approximation of the input N multi-view images.

An advantage of the invention is that for a fixed file size (“rate”), areduced N multi-view output images distortion is obtained. An advantageof the invention is that for a fixed N multi-view output imagesdistortion, a reduced file size (“rate”) is obtained.

The method may be one wherein in step (vii) the N multi-view outputimages are stored.

The method may be one wherein ground-truth dependencies between the Nmulti-view images are used as additional input.

The method may be one wherein depth maps of the N multi-view images areused as additional input.

The method may be one wherein optical flow data of the N multi-viewimages are used as additional input.

According to a 23rd aspect of the invention, there is provided acomputer implemented method of training a first neural network and asecond neural network, the neural networks being for use in lossy imageor video compression, transmission and decoding, the method includingthe steps of:

-   -   (i) receiving N multi-view input training images;    -   (ii) encoding the N multi-view input training images using the        first neural network, to produce a latent representation;    -   (iii) quantizing the latent representation to produce a        quantized latent;    -   (iv) using the second neural network to produce N multi-view        output images from the quantized latent, wherein the N        multi-view output images are an approximation of the N        multi-view input images;    -   (v) evaluating a loss function based on differences between the        N multi-view output images and the N multi-view input images;    -   (vi) evaluating a gradient of the loss function;    -   (vii) back-propagating the gradient of the loss function through        the second neural network and through the first neural network,        to update weights of the second neural network and of the first        neural network; and    -   (viii) repeating steps (i) to (vii) using a set of N multi-view        input training images, to produce a trained first neural network        and a trained second neural network, and    -   (ix) storing the weights of the trained first neural network and        of the trained second neural network.

An advantage of the invention is that, when using the trained firstneural network and the trained second neural network, for a fixed filesize (“rate”), a reduced N multi-view output images distortion isobtained; and for a fixed N multi-view output images distortion, areduced file size (“rate”) is obtained.

The method may be one wherein the loss function is evaluated as aweighted sum of differences between the output images and the inputtraining images, and the estimated bits of the quantized image latents.

The method may be one wherein the steps of the method are performed by acomputer system.

The method may be one wherein the loss function includes using a singleimage depth-map estimation of the N multi-view input training images andthe N multi-view output images and then measuring the distortion betweenthe depth maps of the N multi-view input training images and the Nmulti-view output images.

The method may be one wherein the loss function includes using areprojection into the 3-d world using N multi-view input training imagesand a reprojection into the 3-d world using N multi-view output imagesand a loss measuring the difference of the resulting 3-d worlds.

The method may be one wherein the loss function includes using opticalflow methods that establish correspondence between pixels in Nmulti-view input training images and N multi-view output images and aloss to minimise these resulting flow-maps.

The method may be one wherein positional location information of thecameras/images and their absolute/relative configuration are encoded inthe neural networks as a prior through the training process.

According to a 24th aspect of the invention, there is provided acomputer-implemented method for lossy image or video compression,transmission and decoding, the method including the steps of

-   -   (i) receiving an input satellite/space, hyperspectral or medical        image at a first computer system;    -   (ii) encoding the input image using a first trained neural        network, using the first computer system, to produce a latent        representation;    -   (iii) quantizing the latent representation using the first        computer system to produce a quantized latent;    -   (iv) entropy encoding the quantized latent into a bitstream,        using the first computer system;    -   (v) transmitting the bitstream to a second computer system;    -   (vi) the second computer system entropy decoding the bitstream        to produce the quantized latent;    -   (vii) the second computer system using a second trained neural        network to produce an output satellite/space, hyperspectral or        medical image from the quantized latent, wherein the output        satellite/space, hyperspectral or medical image is an        approximation of the input satellite/space, hyperspectral or        medical image.

An advantage of the invention is that for a fixed file size (“rate”), areduced output satellite/space or medical image distortion is obtained.An advantage of the invention is that for a fixed output satellite/spaceor medical image distortion, a reduced file size (“rate”) is obtained.

The method may be one wherein the output satellite/space, hyperspectralor medical image is stored.

According to a 25th aspect of the invention, there is provided acomputer implemented method of training a first neural network and asecond neural network, the neural networks being for use in lossy imageor video compression, transmission and decoding, the method includingthe steps of:

-   -   (i) receiving an input satellite/space, hyperspectral or medical        training image;    -   (ii) encoding the input satellite/space, hyperspectral or        medical training image using the first neural network, to        produce a latent representation;    -   (iii) quantizing the latent representation to produce a        quantized latent;    -   (iv) using the second neural network to produce an output        satellite/space, hyperspectral or medical image from the        quantized latent, wherein the output satellite/space,        hyperspectral or medical image is an approximation of the input        image;    -   (v) evaluating a loss function based on differences between the        output satellite/space, hyperspectral or medical image and the        input satellite/space, hyperspectral or medical training image;    -   (vi) evaluating a gradient of the loss function;    -   (vii) back-propagating the gradient of the loss function through        the second neural network and through the first neural network,        to update weights of the second neural network and of the first        neural network; and    -   (viii) repeating steps (i) to (vii) using a set of        satellite/space, hyperspectral or medical training images, to        produce a trained first neural network and a trained second        neural network, and    -   (ix) storing the weights of the trained first neural network and        of the trained second neural network.

An advantage of the invention is that, when using the trained firstneural network and the trained second neural network, for a fixed filesize (“rate”), a reduced output satellite/space or medical imagedistortion is obtained; and for a fixed output satellite/space ormedical image distortion, a reduced file size (“rate”) is obtained.

The method may be one wherein the loss function is evaluated as aweighted sum of differences between the output image and the inputtraining image, and the estimated bits of the quantized image latents.

The method may be one wherein the steps of the method are performed by acomputer system.

According to a 26th aspect of the invention, there is provided acomputer implemented method of training a first neural network and asecond neural network, the neural networks being for use in lossy imageor video compression, transmission and decoding, the method includingthe steps of:

-   -   (i) receiving an input training image;    -   (ii) encoding the input training image using the first neural        network, to produce a latent representation;    -   (iii) using the second neural network to produce an output image        from the latent representation, wherein the output image is an        approximation of the input image;    -   (iv) evaluating a loss function based on differences between the        output image and the input training image, plus a weighted term        which evaluates entropy loss with respect to the latent        representation;    -   (v) evaluating a first gradient of the loss function with        respect to parameters of the first neural network, and a second        gradient of the loss function with respect to parameters of the        second neural network;    -   (vi) back-propagating the first gradient of the loss function        through the first neural network, and back-propagating the        second gradient of the loss function through the the second        neural network to update parameters of the first neural network        and of the second neural network; and    -   (vii) repeating steps (i) to (vi) using a set of training        images, to produce a trained first neural network and a trained        second neural network, and    -   (viii) storing the weights of the trained first neural network        and of the trained second neural network.

An advantage of the invention is that, when using the trained firstneural network and the trained second neural network, for a fixed filesize (“rate”), a reduced output image distortion is obtained; and for afixed output image distortion, a reduced file size (“rate”) is obtained.

The method may be one wherein the loss function is evaluated as aweighted sum of differences between the output image and the inputtraining image, and the estimated bits of the quantized image latents.

The method may be one wherein the steps of the method are performed by acomputer system.

The method may be one wherein the entropy loss includes moment matching.

According to a 27th aspect of the invention, there is provided acomputer implemented method of training a first neural network and asecond neural network, the method including the use of a discriminatorneural network, the first neural network and the second neural networkbeing for use in lossy image or video compression, transmission anddecoding, the method including the steps of:

-   -   (i) receiving an input training image;    -   (ii) encoding the input training image using the first neural        network, to produce a latent representation;    -   (iii) using the second neural network to produce an output image        from the latent representation, wherein the output image is an        approximation of the input image;    -   (iv) evaluating a loss function based on differences between the        output image and the input training image;    -   (v) evaluating a first gradient of the loss function with        respect to parameters of the first neural network, and a second        gradient of the loss function with respect to parameters of the        second neural network;    -   (vi) back-propagating the first gradient of the loss function        through the first neural network, and back-propagating the        second gradient of the loss function through the the second        neural network to update parameters of the first neural network        and of the second neural network;    -   (vii) sampling a sample from a predefined prior distribution;    -   (viii) feeding the sample to the discriminator neural network to        obtain a sample realness score;    -   (ix) feeding the latent representation to the discriminator        neural network to obtain a latent representation realness score;    -   (x) evaluating a discriminator loss, which is a function of the        sample realness score, and the latent representation realness        score, multiplied by a weight factor;    -   (xi) evaluating a generator loss, which is a function of the        sample realness score, and the latent representation realness        score, multiplied by the weight factor;    -   (xii) using the generator loss to calculate a third gradient of        the loss function with respect to parameters of the first neural        network;    -   (xiii) using the discriminator loss to calculate a fourth        gradient of the loss function with respect to parameters of the        discriminator neural network;    -   (xiv) back-propagating the third gradient of the loss function        to update parameters of the first neural network;    -   (xv) back-propagating the fourth gradient of the loss function        to update parameters of the discriminator neural network;    -   (xvi) repeating steps (i) to (xv) using a set of training        images, to produce a trained first neural network, a trained        second neural network, and a trained discriminator neural        network;    -   (xvii) storing the parameters of the trained first neural        network, and of the trained second neural network.

An advantage of the invention is that, when using the trained firstneural network and the trained second neural network, for a fixed filesize (“rate”), a reduced output image distortion is obtained; and for afixed output image distortion, a reduced file size (“rate”) is obtained.

The method may be one wherein the steps of the method are performed by acomputer system.

The method may be one wherein the parameters of the traineddiscriminator neural network are stored.

According to a 28th aspect of the invention, there is provided acomputer implemented method of training a first neural network and asecond neural network, the neural networks being for use in lossy imageor video compression, transmission and decoding, the method includingthe steps of

-   -   (i) receiving an input training image;    -   (ii) encoding the input training image using the first neural        network, to produce a latent representation;    -   (iii) using the second neural network to produce an output image        from the latent representation, wherein the output image is an        approximation of the input image;    -   (iv) evaluating a first loss function based on differences        between the output image and the input training image;    -   (v) evaluating a first gradient of the first loss function with        respect to parameters of the first neural network, and a second        gradient of the first loss function with respect to parameters        of the second neural network;    -   (vi) back-propagating the first gradient of the first loss        function through the first neural network, and back-propagating        the second gradient of the first loss function through the        second neural network, to update parameters of the first neural        network and of the second neural network;    -   (vii) sampling a sample from a predefined prior distribution;    -   (viii) evaluating a second loss function, which is an entropy        loss, which is a function of the latent representation and of        the sample, multiplied by a weight factor;    -   (ix) using the second loss function to calculate a third        gradient of the second loss function with respect to parameters        of the first neural network;    -   (x) back-propagating the third gradient of the second loss        function to update parameters of the first neural network;    -   (xi) repeating steps (i) to (x) using a set of training images,        to produce a trained first neural network and a trained second        neural network, and    -   (xii) storing the parameters of the trained first neural network        and of the trained second neural network.

An advantage of the invention is that, when using the trained firstneural network and the trained second neural network, for a fixed filesize (“rate”), a reduced output image distortion is obtained; and for afixed output image distortion, a reduced file size (“rate”) is obtained.

The method may be one wherein the loss function is evaluated as aweighted sum of differences between the output image and the inputtraining image, and the estimated bits of the quantized image latents.

The method may be one wherein the steps of the method are performed by acomputer system.

According to a 29th aspect of the invention, there is provided acomputer-implemented method for lossy image or video compression,transmission and decoding, the method including the steps of

-   -   (i) receiving an input image at a first computer system;    -   (ii) the first computer system passing the input image through a        routing network, the routing network comprising a router and a        set of one or more function blocks, wherein each function block        is a neural network, wherein the router selects a function block        to apply, and passes the output from the applied function block        back to the router recursively, terminating when a fixed        recursion depth is reached, to produce a latent representation;    -   (iii) quantizing the latent representation using the first        computer system to produce a quantized latent;    -   (iv) entropy encoding the quantized latent into a bitstream,        using the first computer system, and including in the bitstream        metainformation relating to routing data of the routing network;    -   (v) transmitting the bitstream to a second computer system;    -   (vi) the second computer system entropy decoding the bitstream        to produce the quantized latent, and to produce the        metainformation relating to the routing data of the routing        network;    -   (vii) the second computer system using the metainformation        relating to the routing data of the routing network to use a        trained neural network to produce an output image from the        quantized latent representation, wherein the output image is an        approximation of the input image.

An advantage of the invention is that for a fixed file size (“rate”), areduced output image distortion is obtained. An advantage of theinvention is that for a fixed output image distortion, a reduced filesize (“rate”) is obtained.

The method may be one wherein in step (vii) the output image is stored.

The method may be one wherein the routing network is trained usingreinforcement learning.

The method may be one wherein the reinforcement learning includescontinuous relaxation.

The method may be one wherein the reinforcement learning includesdiscrete k-best choices.

The method may be one wherein the training approach for optimising theloss/reward function for the routing module includes using a diversityloss.

The method may be one wherein the diversity loss is a temporal diversityloss, or a batch diversity loss.

According to a 30th aspect of the invention, there is provided acomputer-implemented method, using a neural network architecture search(NAS) of determining one or multiple candidate architectures for aneural network for performing AI-based Image/Video Compression, themethod including the steps of:

-   -   (i) maintaining a sequence of neural layer (or operator)        selection processes;    -   (ii) repeatedly performing a candidate architecture forward        pass;    -   (iii) updating a Neural Architecture Search system by using the        feedback of the current candidate sets, and    -   (iv) selecting one, or a group, of candidates of neural        architectures as a final AI-based Image/Video Compression        sub-system; or selecting one, or a group, of candidates of        neural architectures as a particular function module for a final        AI-based Image/Video compression sub-system.

The method may be one wherein the method is applied to operatorselection, or optimal neural cell creation, or optimal micro neuralsearch, or optimal macro neural search.

The method may be one wherein a set of possible operators in the networkis defined, wherein the problem of training the network is a discreteselection process and Reinforcement Learning tools are used to select adiscrete operator per function at each position in the neural network.

The method may be one wherein the Reinforcement Learning treats this asan agent-world problem in which an agent has to choose the properdiscrete operator, and the agent is training using a reward function.

The method may be one wherein Deep Reinforcement Learning, or GaussianProcesses, or Markov Decision Processes, or Dynamic Programming, orMonte Carlo Methods, or a Temporal Difference algorithm, are used.

The method may be one wherein a set of possible operators in the networkis defined, wherein to train the network, Gradient-based NAS approachesare used by defining a specific operator as a linear (or non-linear)combination over all operators of the set of possible operators in thenetwork; then, gradient descent is used to optimise the weight factorsin the combination during training.

The method may be one wherein a loss is included to incentive theprocess to become less continuous and more discrete over time byencouraging one factor to dominate (e.g. GumbelMax with temperatureannealing).

The method may be one wherein a neural architecture is determined forone or more of an Encoder, a Decoder, a Quantisation Function, anEntropy Model, an Autoregressive Module and a Loss Function.

The method may be one wherein the method is combined with auxiliarylosses for AI-based Compression for compression-objective architecturetraining.

The method may be one wherein the auxiliary losses are runtime onspecific hardware-architectures and/or devices, FLOP-count,memory-movement.

According to a 31st aspect of the invention, there is provided acomputer-implemented method for lossy image or video compression,transmission and decoding, the method including the steps of

-   -   (i) receiving an input image at a first computer system;    -   (ii) encoding the input image using a first trained neural        network, using the first computer system, to produce a latent        representation;    -   (iii) quantizing the latent representation using the first        computer system to produce a quantized latent;    -   (iv) in a loop, modifying the quantized latent, so as to        progressively reduce a finetuning loss, to return a finetuned        quantized latent;    -   (v) entropy encoding the finetuned quantized latent into a        bitstream, using the first computer system;    -   (vi) transmitting the bitstream to a second computer system;    -   (vii) the second computer system entropy decoding the bitstream        to produce the finetuned quantized latent;    -   (viii) the second computer system using a second trained neural        network to produce an output image from the finetuned quantized        latent, wherein the output image is an approximation of the        input image.

An advantage of the invention is that for a fixed file size (“rate”), areduced output image distortion is obtained. An advantage of theinvention is that for a fixed output image distortion, a reduced filesize (“rate”) is obtained.

The method may be one wherein the finetuning loss measures one of, or acombination of: a rate of the modified quantized latent, or a distortionbetween the current decoder prediction of the output image and the inputimage, or a distortion between the current decoder prediction of theoutput image and a decoder prediction of the output image using thequantized latent from step (iii).

The method may be one wherein the loop in step (iv) ends when themodified quantized latent satisfies an optimization criterion.

The method may be one wherein in step (iv), the quantized latent ismodified using a 1st-order optimization method, or using a 2nd-orderoptimization method, or using Monte-Carlo, Metropolis-Hastings,simulated annealing, or other greedy approaches.

According to a 32nd aspect of the invention, there is provided acomputer-implemented method for lossy image or video compression,transmission and decoding, the method including the steps of

-   -   (i) receiving an input image at a first computer system;    -   (ii) encoding the input image using a first trained neural        network, using the first computer system, to produce a latent        representation;    -   (iii) in a loop, modifying the latent representation, so as to        progressively reduce a finetuning loss, to return a finetuned        latent representation;    -   (iv) quantizing the finetuned latent representation using the        first computer system to produce a quantized latent;    -   (v) entropy encoding the quantized latent into a bitstream,        using the first computer system;    -   (vi) transmitting the bitstream to a second computer system;    -   (vii) the second computer system entropy decoding the bitstream        to produce the quantized latent;    -   (viii) the second computer system using a second trained neural        network to produce an output image from the quantized latent,        wherein the output image is an approximation of the input image.

An advantage of the invention is that for a fixed file size (“rate”), areduced output image distortion is obtained. An advantage of theinvention is that for a fixed output image distortion, a reduced filesize (“rate”) is obtained.

The method may be one wherein the finetuning loss measures one of, or acombination of a rate of the quantized latent, or a distortion betweenthe current decoder prediction of the output image and the input image,or a distortion between the current decoder prediction of the outputimage and a decoder prediction of the output image using the quantizedlatent from step (iv).

The method may be one wherein the loop in step (iii) ends when themodified latent satisfies an optimization criterion.

The method may be one wherein in step (iii), the latent is modifiedusing a 1st-order optimization method, or using a 2nd-order optimizationmethod, or using Monte-Carlo, Metropolis-Hastings, simulated annealing,or other greedy approaches.

According to a 33rd aspect of the invention, there is provided acomputer-implemented method for lossy image or video compression,transmission and decoding, the method including the steps of

-   -   (i) receiving an input image at a first computer system;    -   (ii) in a loop, modifying the input image, so as to        progressively reduce a finetuning loss, to return a finetuned        input image;    -   (iii) encoding the finetuned input image using a first trained        neural network, using the first computer system, to produce a        latent representation;    -   (iv) quantizing the latent representation using the first        computer system to produce a quantized latent;    -   (v) entropy encoding the quantized latent into a bitstream,        using the first computer system;    -   (vi) transmitting the bitstream to a second computer system;    -   (vii) the second computer system entropy decoding the bitstream        to produce the quantized latent;    -   (viii) the second computer system using a second trained neural        network to produce an output image from the quantized latent,        wherein the output image is an approximation of the input image.

An advantage of the invention is that for a fixed file size (“rate”), areduced output image distortion is obtained. An advantage of theinvention is that for a fixed output image distortion, a reduced filesize (“rate”) is obtained.

The method may be one wherein the finetuning loss measures one of, or acombination of a rate of the quantized latent, or a distortion betweenthe current decoder prediction of the output image and the input image,or a distortion between the current decoder prediction of the outputimage and a decoder prediction of the output image using the quantizedlatent from step (iv).

The method may be one wherein the loop in step (ii) ends when themodified input image satisfies an optimization criterion.

The method may be one wherein in step (ii), the input image is modifiedusing a 1st-order optimization method, or using a 2nd-order optimizationmethod, or using Monte-Carlo, Metropolis-Hastings, simulated annealing,or other greedy approaches.

According to a 34th aspect of the invention, there is provided acomputer-implemented method for lossy image or video compression,transmission and decoding, the method including the steps of

-   -   (i) receiving an input image at a first computer system;    -   (ii) encoding the input image using a first trained neural        network, using the first computer system, to produce a latent        representation;    -   (iii) quantizing the latent representation using the first        computer system to produce a quantized latent;    -   (iv) entropy encoding the quantized latent into a bitstream,        using the first computer system;    -   (v) transmitting the bitstream to a second computer system;    -   (vi) the second computer system entropy decoding the bitstream        to produce the quantized latent;    -   (vii) the second computer system analyzing the quantized latent        to produce parameters;    -   (viii) the second computer system using the produced parameters        to modify weights of a second trained neural network;    -   (ix) the second computer system using the second trained neural        network including the modified weights to produce an output        image from the quantized latent, wherein the output image is an        approximation of the input image.

An advantage of the invention is that for a fixed file size (“rate”), areduced output image distortion is obtained. An advantage of theinvention is that for a fixed output image distortion, a reduced filesize (“rate”) is obtained.

The method may be one wherein the parameters are a discrete perturbationof the weights of the second trained neural network.

The method may be one wherein the weights of the second trained neuralnetwork are perturbed by a perturbation function that is a function ofthe parameters, using the parameters in the perturbation function.

According to a 35th aspect of the invention, there is provided acomputer-implemented method for lossy image or video compression,transmission and decoding, the method including the steps of:

-   -   (i) receiving an input image at a first computer system;    -   (ii) encoding the input image using a first trained neural        network, using the first computer system, to produce a latent        representation;    -   (iii) quantizing the latent representation using the first        computer system to produce a quantized latent;    -   (iv) the first computer system optimizing a binary mask using        the quantized latent;    -   (iv) entropy encoding the quantized latent and the binary mask        into a bitstream, using the first computer system;    -   (vi) transmitting the bitstream to a second computer system;    -   (vi) the second computer system entropy decoding the bitstream        to produce the quantized latent, and to produce the binary mask;    -   (vii) the second computer system using the binary mask to modify        a convolutional network of a second trained neural network;    -   (ix) the second computer system using the second trained neural        network including the modified a convolutional network to        produce an output image from the quantized latent, wherein the        output image is an approximation of the input image.

An advantage of the invention is that for a fixed file size (“rate”), areduced output image distortion is obtained. An advantage of theinvention is that for a fixed output image distortion, a reduced filesize (“rate”) is obtained.

The method may be one wherein in step (iv), the binary mask is optimizedusing a ranking based method, or using a stochastic method, or using asparsity regularization method.

According to a 36th aspect of the invention, there is provided acomputer-implemented method for lossy image or video compression,transmission and decoding, the method including the steps of

-   -   (i) receiving an input image at a first computer system;    -   (ii) encoding the input image using a first trained neural        network, using the first computer system, to produce a latent        representation, and to identify nonlinear convolution kernels;    -   (iii) quantizing the latent representation using the first        computer system to produce a quantized latent;    -   (iv) entropy encoding the quantized latent and an identification        of the identified nonlinear convolution kernels into a        bitstream, using the first computer system;    -   (v) transmitting the bitstream to a second computer system;    -   (vi) the second computer system entropy decoding the bitstream        to produce the quantized latent, and to identify the nonlinear        convolution kernels;    -   (vii) the second computer system conditioning a second trained        neural network using the identified nonlinear convolution        kernels, to produce a linear neural network;    -   (viii) the second computer system using the second trained        neural network which has been conditioned using the identified        nonlinear convolution kernels to produce a linear neural        network, to produce an output image from the quantized latent,        wherein the output image is an approximation of the input image.

An advantage of the invention is that for a fixed file size (“rate”), areduced output image distortion is obtained. An advantage of theinvention is that for a fixed output image distortion, a reduced filesize (“rate”) is obtained.

The method may be one wherein the linear neural network is a purelylinear neural network.

According to a 37th aspect of the invention, there is provided acomputer-implemented method for lossy image or video compression,transmission and decoding, the method including the steps of:

-   -   (i) receiving an input image at a first computer system;    -   (ii) encoding the input image using a first trained neural        network, using the first computer system, to produce a latent        representation, and to identify adaptive (or input-specific)        convolution (activation) kernels;    -   (iii) quantizing the latent representation using the first        computer system to produce a quantized latent;    -   (iv) entropy encoding the quantized latent and an identification        of the identified adaptive (or input-specific) convolution        (activation) kernels into a bitstream, using the first computer        system;    -   (v) transmitting the bitstream to a second computer system;    -   (vi) the second computer system entropy decoding the bitstream        to produce the quantized latent, and to identify the adaptive        (or input-specific) convolution (activation) kernels;    -   (vii) the second computer system conditioning a second trained        neural network using the identified adaptive (or input-specific)        convolution (activation) kernels, to produce a linear neural        network;    -   (viii) the second computer system using the second trained        neural network which has been conditioned using the identified        adaptive (or input-specific) convolution (activation) kernels to        produce a linear neural network, to produce an output image from        the quantized latent, wherein the output image is an        approximation of the input image.

An advantage of the invention is that for a fixed file size (“rate”), areduced output image distortion is obtained. An advantage of theinvention is that for a fixed output image distortion, a reduced filesize (“rate”) is obtained.

The method may be one wherein the linear neural network is a purelylinear neural network.

According to a 38th aspect of the invention, there is provided acomputer implemented method of training a first neural network, a secondneural network, a third neural network, and a fourth neural network, theneural networks being for use in lossy image or video compression,transmission and decoding, the method including the steps of:

-   -   (i) receiving an input training image;    -   (ii) encoding the input training image using the first neural        network, to produce a y latent representation;    -   (iii) quantizing the y latent representation to produce a        quantized y latent;    -   (iv) encoding the y latent using the third neural network, to        produce a k latent representation;    -   (v) quantizing the k latent representation to produce a        quantized k latent;    -   (vi) processing the quantized k latent using the fourth neural        network to obtain parameters identifying nonlinear convolution        kernels of the y latent;    -   (vii) conditioning the second neural network, wherein the second        neural network includes a plurality of units arranged in series,        each unit comprising a convolutional layer followed by an        activation kernel, wherein the units are conditioned using the        identified nonlinear convolution kernels to produce a linear        neural network;    -   (viii) using the conditioned the second neural network to        produce an output image from the quantized y latent, wherein the        output image is an approximation of the input training image;    -   (ix) evaluating a loss function based on differences between the        output image and the input training image;    -   (x) evaluating a gradient of the loss function;    -   (xi) back-propagating the gradient of the loss function through        the second neural network, through the fourth neural network,        through the third neural network and through the first neural        network, to update weights of the first, second, third and        fourth neural networks; and    -   (xii) repeating steps (i) to (xi) using a set of training        images, to produce a trained first neural network, a trained        second neural network, a trained third neural network and a        trained fourth neural network, and    -   (xiii) storing the weights of the trained first neural network,        the trained second neural network, the trained third neural        network and the trained fourth neural network.

According to a 39th aspect of the invention, there is provided acomputer implemented method of training a first neural network, a secondneural network, a third neural network, and a fourth neural network, theneural networks being for use in lossy image or video compression,transmission and decoding, the method including the steps of:

-   -   (i) receiving an input training image;    -   (ii) encoding the input training image using the first neural        network, to produce a y latent representation;    -   (iii) quantizing the y latent representation to produce a        quantized y latent;    -   (iv) encoding the y latent using the third neural network, to        produce a k latent representation;    -   (v) quantizing the k latent representation to produce a        quantized k latent;    -   (vi) processing the quantized k latent using the fourth neural        network to obtain parameters identifying adaptive (or        input-specific) convolution (activation) kernels of the y        latent;    -   (vii) conditioning the second neural network, wherein the second        neural network includes a plurality of units arranged in series,        each unit comprising a convolutional layer followed by an        activation kernel, wherein the units are conditioned using the        identified adaptive (or input-specific) convolution (activation)        kernels to produce a linear neural network;    -   (viii) using the conditioned the second neural network to        produce an output image from the quantized y latent, wherein the        output image is an approximation of the input training image;    -   (ix) evaluating a loss function based on differences between the        output image and the input training image;    -   (x) evaluating a gradient of the loss function;    -   (xi) back-propagating the gradient of the loss function through        the second neural network, through the fourth neural network,        through the third neural network and through the first neural        network, to update weights of the first, second, third and        fourth neural networks; and    -   (xii) repeating steps (i) to (xi) using a set of training        images, to produce a trained first neural network, a trained        second neural network, a trained third neural network and a        trained fourth neural network, and    -   (xiii) storing the weights of the trained first neural network,        the trained second neural network, the trained third neural        network and the trained fourth neural network.

An advantage of each of the above two inventions is that, when using thetrained first neural network, the trained second neural network, thetrained third neural network and the trained fourth neural network, fora fixed file size (“rate”), a reduced output image distortion isobtained; and for a fixed output image distortion, a reduced file size(“rate”) is obtained.

The method may be one wherein the loss function is evaluated as aweighted sum of differences between the output image and the inputtraining image, and the estimated bits of the quantized image latents.

The method may be one wherein the steps of the method are performed by acomputer system.

The method may be one wherein initially the units are stabilized byusing a generalized convolution operation, and then after a firsttraining the weights of the trained first neural network, the trainedthird neural network and the trained fourth neural network, are storedand frozen; and then in a second training process the generalizedconvolution operation of the units is relaxed, and the second neuralnetwork is trained, and its weights are then stored.

The method may be one wherein the second neural network is proxy trainedwith a regression operation.

The method may be one wherein the regression operation is linearregression, or Tikhonov regression.

The method may be one wherein initially the units are stabilized byusing a generalized convolution operation or optimal convolution kernelsgiven by linear regression and/or Tikhonov stabilized regression, andthen after a first training the weights of the trained first neuralnetwork, the trained third neural network and the trained fourth neuralnetwork, are stored and frozen; and then in a second training processthe generalized convolution operation is relaxed, and the second neuralnetwork is trained, and its weights are then stored.

The method may be one wherein in a first training period jointoptimization is performed for a generalised convolution operation of theunits, and a regression operation of the second neural network, with aweighted loss function, whose weighting is dynamically changed over thecourse of network training, and then the weights of the trained firstneural network, the trained third neural network and the trained fourthneural network, are stored and frozen; and then in a second trainingprocess the generalized convolution operation of the units is relaxed,and the second neural network is trained, and its weights are thenstored.

Aspects of the invention may be combined.

In the above methods and systems, an image may be a single image, or animage may be a video image, or images may be a set of video images, forexample.

The above methods and systems may be applied in the video domain.

For each of the above methods, a related system may be provided.

For each of the above training methods, a related computer programproduct may be provided.

BRIEF DESCRIPTION OF THE FIGURES

Aspects of the invention will now be described, by way of example(s),with reference to the following Figures, in which:

FIG. 1 shows a schematic diagram of an artificial intelligence(AI)-based compression process, including encoding an input image xusing a neural network E( . . . ), and decoding using a neural networkD( . . . ), to provide an output image {circumflex over (x)}. Runtimeissues are relevant to the Encoder. Runtime issues are relevant to theDecoder. Examples of issues of relevance to parts of the process areidentified.

FIG. 2 shows a schematic diagram of an artificial intelligence(AI)-based compression process, including encoding an input image xusing a neural network E( . . . ), and decoding using a neural networkD( . . . ), to provide an output image {circumflex over (x)}, and inwhich there is provided a hyper encoder and a hyper decoder. “Dis”denotes elements of a discriminator network.

FIG. 3 shows an example of three types of image segmentation approaches:classification, object detection, and instance segmentation.

FIG. 4 shows an example of a generic segmentation and compressionpipeline which sends the image through a segmentation module to producea useful segmented image. The output of the segmentation pipeline isprovided into the compression pipeline and also used in the losscomputation for the network. The compression pipeline has beengeneralised and simplified into two individual modules called theEncoder and Decoder which may in turn be composed of submodules.

FIG. 5 shows an example of instantiation of the generic segmentation andcompression pipeline from FIG. 4 where instance segmentation isutilised.

FIG. 6 shows an example of instantiation of the generic segmentation andcompression pipeline from FIG. 4 where semantic segmentation isutilised.

FIG. 7 shows an example of instantiation of the generic segmentation andcompression pipeline from FIG. 4 where object segmentation is utilised.

FIG. 8 shows an example of instantiation of the generic segmentation andcompression pipeline from FIG. 4 where block-based segmentation isutilised.

FIG. 9 shows an example pipeline of the training of the SegmentationModule in FIG. 4 , if the module is parameterized as a neural network,where Ls is the loss. The segmentation ground truth label x_(s) may beof any type required by the segmentation algorithm. This figure usesinstance segmentation as an example.

FIG. 10 shows an example training pipeline to produce the segments usedto train the classifier as shown in FIG. 11 . Each pair of Encoder;Decoder produces patches with a particular loss function L_(i) whichdetermines the types of compression distortion each compression networkproduces.

FIG. 11 shows an example of a loss classifier which is trained on thepatches produced by the set of networks in FIG. 10 . {{circumflex over(x)}_(i)} is a set of the same ground truth patch produced by all the ncompression networks in FIG. 10 with different losses. The classifier istrained to select the optimal distortion type based on selectionsperformed by humans. The Human Preference Data is collected from a humanstudy. The classifier must learn to select the distortion type preferredby humans.

FIG. 12 shows an example of dynamic distortion loss selections for imagesegments. The trained classifier from FIG. 11 is used to select theoptimal distortion type for each image segment. d_(i) indicates thedistortion function and D_(i)′ indicates the distortion loss for patchi.

FIG. 13 shows a visual example of RGB and YCbCr components of an image.(a) Conversion of RGB image to YCbCr colour-space. (b) Representation ofan RGB image as separate colour channels, converted into YCbCrcolour-space; note that a combination of all the colour channel RGB areused for the YCbCr channels.

FIG. 14 shows an example flow diagram of components of a typicalautoencoder.

FIG. 15 shows an example flow diagram of a typical autoencoder atnetwork training mode.

FIG. 16 shows a PDF of a continuous prior, p_(yi) which describes thedistribution of the raw latent y_(i). Upon integer-roundingquantisation, the PMF P_(ŷi) is obtained though non-differentiable (seenby the discrete bars). By simulating quantisation through additive noiseperturbation, in this example from a unit-width uniform distribution(solid box, scaled down for visualisation), we obtain a continuouslyrelaxed quantised prior distribution p_(ŷi)=p_(y) _(i) *U(−½, ½).

FIG. 17 shows an example Venn diagram showcasing relationship betweendifferent classes of (continuous) probability distributions. The truelatent distribution exists within this map of distribution classes; thejob of the entropy model is to get as close as possible to it. Note thatall distributions are non-parametric (since these generalise parametricdistributions), and all parametric and factorisable distributions canconstitute at least one component of a mixture model.

FIG. 18 shows an example flow diagram of an autoencoder with ahyperprior as entropy model to latents ŷ. Note how the architecture ofthe hypernetwork mirrors that of the main autoencoder. The inputs to thehyperencoder h_(enc)(•) can be arbitrary, so long as they are availableat encoding. The hyperentropy model of {circumflex over (z)} can bemodelled as a factorised prior, conditional model, or even anotherhyperprior. Ultimately, the hyperdecoder h_(dec)({circumflex over (z)})outputs the entropy parameters for the latents, ϕ_(y).

FIG. 19 shows a demonstration of an unsuitability of a factorisablejoint distribution (independent) to adequately model a jointdistribution with dependent variables (correlated), even with the samemarginal distributions.

FIG. 20 shows typical parametric distributions considered under anoutlined method. This list is by no means exhaustive, and is mainlyincluded to showcase viable examples of parametric distributions thatcan be used as prior distribution.

FIG. 21 shows different partitioning schemes of a feature map in arrayformat. (a) 2D contiguous 2×2-block partitioning. (b) 2D contiguous4×4-block partitioning. (c) 2D overlapping 4×4-block partitioning(borders) with a stride size of 2 (dashed lines) along spatialdimensions. (d) 3D contiguous 2×2×3-block partitioning. (e) variouscontiguous block sizes and shapes, similar to coding tree unitstructures utilised in H.265 and H.266 compression engines. (f) anarbitrary, seemingly unstructured but equally valid partitioning schemeas the others.

FIG. 22 shows an example visualisation of a MC- or QMC-based samplingprocess of a joint density function in two dimensions. The samples areabout a centroid ŷ with integration boundary Ω marked out by therectangular area of width (b₁-a₁) and (b₂-a₂). As per Equation (2.13),the probability mass equals the average of all probability densityevaluations within Ω times the rectangular area.

FIG. 23 shows an example of how a 2D-Copula could look like.

FIG. 24 shows an example of how to use Copula to sample correlatedrandom variables of an arbitrary distribution.

FIG. 25 shows an indirect way to get a joint distribution usingcharacteristic functions.

FIG. 26 shows a mixture model comprising three MVNDs, eachparametrisable as individual MVNDs, and then summed with weightings.

FIG. 27 shows an example of a PDF for a piece-wise linear distribution,a non-parametric probability distribution type, defined across integervalues along the domain.

FIG. 28 shows example stimulus tests: {circumflex over (x)}₁ to{circumflex over (x)}₃ represent images with various levels of AI basedcompression distortion applied. h represent the results humans assessorswould give the image for visual quality.

FIG. 29 shows example 2FAC: {circumflex over (x)}_(1,A) and {circumflexover (x)}_(1,B) represent two version of an image with various levels ofAI based compression distortion applied. h represent the results humansassessors would give the image for visual quality, where a value of 1would mean the human prefers that image over other. x here is the GTimage.

FIG. 30 shows an example in which x represents the ground truth images,{circumflex over (x)} represents the distorted images and s representsthe visual loss score. This figure represents a possible architecture tolearn visual loss score. The blue, green and turquoise block couldrepresent conv+relu+batchnorm block or any other combination of neuralnetwork layers. The output value can be left free, or bounded using (butnot limited to) a function such as tanh or sigmoid.

FIG. 31 shows an example in which x₂ and x₃ represent downsampledversions of the same input image, x₁. The networks with parameters θ areinitialised randomly. The output of each network, from s₁ to s₁ isaveraged, and used as input to the L value as shown in Algorithm 4.1.

FIG. 32 shows an example in which the parameters θ of the three networksare randomly initialised. During training, the output of each network,from s₁ to s₃ is used along with the GT values to create three lossfunctions L₁ to L₃ used to optimise the parameters of their respectivenetworks.

FIG. 33 shows an example in which the blue and green blocks representconvolution+relu+batchnorm blocks while the turquoise blocks representfully connected layers. The alternatives choices. Square bracketsrepresent depth concatenation. Here x₁ and x₂ represent distortedimages, and x_(GT) represents the ground truth image.

FIG. 34 shows a plot of the rounding function to nearest integer (withthe “round-to-even” convention) Q(y_(i))=└y_(i)┐. Note how the gradientof the function is zero almost everywhere, with exceptions ofhalf-integers where the gradient is infinity.

FIG. 35 shows an example of a flow diagram of a typical autoencoderunder its training regime. The diagram outlines the pathway for forwardpropagation with data to evaluate the loss, as well as the backward flowof gradients emanating from each loss component.

FIG. 36 shows an example of how quantisation discretises a continuousprobability density p_(yi) into discrete probability masses P_(ŷi). Eachprobability mass is equal to the area p_(yi) for the quantisationinterval, Δ_(i) (here equal to 1.0).

FIG. 37 shows example typical quantisation proxies that areconventionally employed. Unless specified under the “Gradientoverriding?” column, the backward function is the analytical derivativeof the forward function. This listing is not exhaustive and serves as ashowcase of viable examples for quantisation proxies.

FIG. 38 shows an example of uniform noise quantisation {tilde over(Q)}(y_(i))=y_(i)+ε_(i), ε_(i)˜U(−0.5, +0.5) gives rise to a continuousrelaxation of the PMF P_(ŷi). The resulting distribution is equivalentof the base distribution convolved with a unit uniform distribution,p_(ŷi)=p_(yi)*U(−0.5, +0.5), and coincides with all values of the PMF.

FIG. 39 shows an example flow diagram of the forward propagation of thedata through the quantisation proxy, and the backpropagation ofgradients through a custom backward (gradient overwriting) function.

FIG. 40 shows example rate loss curves and their gradients. Left:Laplacian entropy model. Since the gradient magnitude is constant beyondΔ/2, the gradient signal would always be equivalent for a rounded latentvariable ŷ_(i)=└y_(i)┐=y_(i)+ε(y_(i)) as for a noise-added latent if|y_(i)|>Δ. Right: Gaussian entropy model. The same does not apply for aGaussian entropy model, where it is clear that∂L_(R)/∂ŷ_(i)≠∂L_(R)/∂y_(i).

FIG. 41 is an example showing discontinuous loss magnitudes and gradientresponses if the variables are truly quantised to each integer position.Left: Laplacian entropy model. Right: Gaussian entropy model.

FIG. 42 is an example showing a histogram visualisation of the twintower effect of latents y, whose values cluster around −0.5 and +0.5.

FIG. 43 shows an example with (a) split quantisation with a gradientoverwriting function for the distortion component of quantisation. (b)Soft-split quantisation with a detach operator as per Equation (5.19) toredirect gradient signals of the distortion loss through the ratequantisation proxy.

FIG. 44 shows an example flow diagram of a typical setup with a QuantNetmodule, and the gradient flow pathways. Note that true quantisationbreaks any informative gradient flow.

FIG. 45 shows an example in which there is provided, in the upper twoplots: Visualisation of the entropy gap, and the difference in assignedprobability per point for unquantised (or noise quantised) latentvariable versus quantised (or rounded) latent variable. Lower two plots:Example of the soft-discretisation of the PDF for a less “smooth”continuous relaxations of the discrete probability model.

FIG. 46 shows an example of a single-input AI-based Compression setting.

FIG. 47 shows an example of AI-based Compression for stereo inputs.

FIG. 48 shows an example of stereo image compression which requires anadditional loss term for 3D-viewpoint consistency.

FIG. 49 shows an example including adding stereo camera position andconfiguration data into the neural network.

FIG. 50 shows an example including pre- and post-processing data fromdifferent sensors.

FIG. 51 shows an example of temporal-spatial constraints.

FIG. 52 shows an example including changing inputs to modelspatial-temporal constraints.

FIG. 53 shows an example including keeping inputs and modelspatial-temporal constraints through meta-information on the input data.

FIG. 54 shows an example including keeping inputs and modelspatial-temporal constraints through meta-information on (previously)queued latent-space data.

FIG. 55 shows an example including specialising a codec on specificobjectives. This implies changing Theta after re-training.

FIG. 56 shows an upper triangular matrix form U and a lower triangularmatrix form L.

FIG. 57 shows a general Jacobian form for mapping from

^(N) to

^(N).

FIG. 58 shows an example of a diagram of a squeezing operation. Inputfeature map on left, output on right. Note, the output has a quarter ofthe spatial resolution, but double the number of channels.

FIG. 59 shows an example FlowGAN diagram.

FIG. 60 shows an example compression and decompression pipeline of animage x using a single INN (drawn twice for visualisation purposes). Qis quantisation operation, AE and AD are arithmetic encoder and decoderrespectively. Entropy models and hyperpriors are not pictured here forthe sake of simplicity.

FIG. 61 shows an example architecture of Integer Discrete Flowtransforming input x into z, split in z₁, z₂ and z₃.

FIG. 62 shows an example architecture of a single IDF block. It containsthe operations and layers described in the Introduction section 7.1,except for Permute channels, which randomly shuffles the order of thechannels in the feature map. This is done to improve thetransformational power of the network by processing different randomchannels in each block.

FIG. 63 shows an example compression pipeline with an INN acting as anadditional compression step, similarly to a hyperprior. We introduce anadditional variable w and apply the entropy model on this variableinstead of the latent space 9.

FIG. 64 shows an example in which partial output y of factor-out layeris fed to a neural network, that is used to predict the parameters ofthe prior distribution that models the output.

FIG. 65 shows an example in which output of factor-out layer, isprocessed by a hyperprior and then is passed to the parameterisationnetwork.

FIG. 66 shows an example illustration of MI, where p(y) and p(y|x) iscomputed using INN transformations. Here [x, y] represents a depthconcatenation of the inputs.

FIG. 67 shows an example compression pipeline that sendsmeta-information in the form of the decoder weights. The decoder weightsw are retrieved from the decoder at encode-time, then they are processedby an INN to an alternate representation z with an entropy model on it.This is then sent as part of the bitstream.

FIG. 68 shows an example Venn diagram of the entropy relationships fortwo random variables X and Y.

FIG. 69 shows an example in which a compression pipeline is modelled asa simple channel where the input x is corrupted by noise n.

FIG. 70 shows an example of training of the compression pipeline withthe mutual information estimator. The gradients propagate along thedashed lines in the figure. N and S are neural networks to predict σ_(n)² and σ_(s) ², using eq. (8.7). n={circumflex over (x)}−x.

FIG. 71 shows an example of training of the compression pipeline withthe mutual information estimator in a bi-level fashion. The gradientsfor the compression network propagate within the compression networkarea. Gradients for the networks N and S propagate only within the areabounded by the dashed lines. N and S are trained separately from thecompression network using negative log-likelihood loss. N and S areneural networks to predict σ_(n) ² and σ_(s) ² using eq. (8.7).n={circumflex over (x)}−x.

FIG. 72 shows an example simplified compression pipeline with an inputx, output {circumflex over (x)}, and an encoder-decoder component.

FIG. 73 shows an example including maximising the mutual information ofI(y; n) where the MI Estimator can be parameterized by a closed formsolution given by P.

FIG. 74 shows an example including maximising the mutual information ofL=I(y; n) where the Critic can be parameterized as a neural network. Themutual information estimate of the critic depends on the mutualinformation bound, such as InfoNCE, NWJ, JS, TUBA etc,. The compressionnetwork and critic are trained in a bi-level fashion.

FIG. 75 shows an example of an AAE where the input image is denoted as xand the latent space is z. The encoder network q(z|x) generates thelatent space that is then fed to both the decoder (top right) and thediscriminator (bottom right). The discriminator is also fed samples fromthe prior distribution p(z) (bottom left).

FIG. 76 shows a list of losses that can be used in adversarial setupsframed as class probability estimation (for example, vanilla GAN).

FIG. 77 shows an example diagram of the Wasserstein distance between twounivariate distributions, in the continuous (above) and discrete (below)cases. The operation in Equation (9.10) is equivalent to calculating thedifference between the cumulative density/mass functions. Since wecompare samples drawn from distributions, we are interested in thediscrete case.

FIG. 78 shows an example of multivariate sampling used with Wassersteindistance. We sample a tensor s with 3 channels and whose pixels we namep_(u,v) where u and v are the horizontal and vertical coordinates of thepixel. Each pixel is sampled from a Normal distribution with a differentmean and variance.

FIG. 79 shows an example of an autoencoder using Wasserstein loss withquantisation. The input image x is processed into a latent space y. Thelatent space is quantised, and Wasserstein (WM) is applied between thisand a target ŷ_(t) sampled from a discrete distribution.

FIG. 80 shows an example of an autoencoder using Wasserstein losswithout quantisation. In this method the unquantised y is directlycompared against ŷ_(t), which is still sampled from a discretedistribution. Note, during training the quantisation operation Q is notused, but we have to use it at inference time to obtain a strictlydiscrete latent.

FIG. 81 shows an example model architecture with side-information. Theencoder network generates moments μ and σ together with the latent spacey: the latent space is then normalised by these moments and trainedagainst a normal prior distribution with mean zero and variance 1. Whendecoded, the latent space is denormalised using the same mean andvariance. Note that the entropy divergence used in this case isWasserstein, but in practice the pipeline is not limited to that.Additionally, note that the mean and variance are predicted by theencoder itself, but in practice they can also be predicted by a separatehyperprior network.

FIG. 82 shows an example of a pipeline using a categorical distributionwhose parameters are predicted by a hyperprior network (made up ofhyper-encoder HE and hyper-decoder HD). Note that we convert thepredicted values to real probabilities with an iterative method, andthen use a differentiable sampling strategy to obtain ŷ_(t).

FIG. 83 shows an example PDF of a categorical distribution with support{0, 1, 2}. The length of the bars represents the probability of eachvalue.

FIG. 84 shows an example of sampling from a categorical distributionwhile retaining differentiability with respect to the probability valuesp. Read from bottom-left to right.

FIG. 85 shows an example of a compression pipeline with INN and AAEsetup. An additional latent w is introduced, so that the latent y isdecoupled from the entropy loss (joint maximum likelihood andadversarial training with the help of Disc). This pipeline also workswith non-adversarial losses such as Wasserstein, where the discriminatornetwork is not needed.

FIG. 86 shows a roofline model showing a trade off between FLOPs andMemory.

FIG. 87 shows an example of a generalised algorithm vs multi-classmulti-algorithm vs MTL.

FIG. 88 shows an example in which in a routing network, different inputscan travel different routes through the network.

FIG. 89 shows an example data flow of a routing network.

FIG. 90 shows an example of an asymmetric routing network.

FIG. 91 shows an example of training an (asymmetric) routing network.

FIG. 92 shows an example of using permutation invariant set networks asrouting modules to guarantee size independence when using neuralnetworks as Routers.

FIG. 93 shows an example of numerous ways of designing a routingnetwork.

FIG. 94 shows an example illustration of using Routing Networks as theAI-based Compression pipeline.

FIG. 95 shows an example including the use of convolution blocks. Symbolo_(ij) represents the output of the ith image and jth conv-block. ō isthe average output over the previous conv-blocks. All conv-blocks acrossnetworks share weights and have a downsample layer at the end. Dottedboundaries represent outputs, while solid boundaries are convolutions.For I_(n), arrows demonstrate how o_(n1) and ō are computed where ⊕represents a symmetric accumulation operation. Fully connected layersare used to regress the parameter.

FIG. 96 shows examples of grids.

FIG. 97 shows a list, in which all conv. layers have a stride of 1 andall downsample layers have a stride of 2. The concat column representsthe previous layers which are depth-concatenated with the current input,a dash (-) represents no concatenation operation. Filter dim is in theformat [filter height, filter width, input depth, output depth]. δrepresents the globally averaged state from output of all previousblocks. The compress layer is connected with a fully connected layerwith a thousand units, which are all connected to one unit whichregresses the parameter.

FIG. 98 shows an example flow diagram of forward propagation through aneural network module (possibly be an encoder, decoder, hypernetwork orany arbitrary functional mapping), which here is depicted asconstituting convolutional layers but in practice could be any linearmapping. The activation functions are in general interleaved with thelinear mappings, giving the neural network its nonlinear modellingcapacity. Activation parameters are learnable parameters that arejointly optimised for with the rest of the network.

FIG. 99 shows examples of common activation functions in deep learningliterature such as ReLU, Tanh, Softplus, LeakyReLU and GELU. The PAU oforder (m=5, n=4) can very precisely mimic each mapping within thedisplayed range x∈[−3, 3].

FIG. 100 shows an example of spectral upsampling & downsampling methodsvisualized in a tensor perspective where the dimensions are as follows[batch, channel, height, width].

FIG. 101 shows an example of a stacking and stitching method (withoverlap) which are shown for a simple case where the window height W_(H)is the same as the image height and the width W_(W) is half of the imagewidth. Similarly, the stride window's height and width are half of thatof the sliding window.

FIG. 102 shows an example visualisation of an averaging mask used forthe case when the stacking operation includes the overlapping regions.

FIG. 103 shows an example visualising the Operator Selection processwithin an AI-based Compression Pipeline.

FIG. 104 shows an example Macro Architecture Search by pruning anover-complex start architecture.

FIG. 105 shows an example Macro Architecture Search with a bottom-upapproach using a controller-network.

FIG. 106 shows an example of an AI-based compression pipeline. Inputmedia {circumflex over (x)}∈

^(M) is transformed through an encoder E, creating a latent y∈

^(n). The latent y is

quantized, becoming an integer-valued vector ŷ∈Z^(n). During training ofthe pipeline, a probability model on ŷ is used to compute estimate therate R (the length of the bitstream). During use, the probability modelis used by an arithmetic encoder & arithmetic decoder, which transformthe quantized latent into a bitstream (and vice versa). On decode, thequantized latent is sent through a decoder D, returning a prediction{circumflex over (x)} approximating x.

FIG. 107 shows an example illustration of generalization vsspecialization for Example 1 of section 14.1.2. In (a), θ is the closestto all other points, on average. In (b), θ is not the closest point to{circumflex over (x)}₁.

FIG. 108 shows an example plot of the hard thresholding and shrinkagefunctions, with s=1.

FIG. 109 shows an example of an AI-based compression pipeline withfunctional fine-tuning. In addition to encoding the latents ŷ∈Z^(n), anadditional parameter ϕ is encoded and decoded. ϕ is a parameter thatcontrols some of the behaviour of the decoder. The variable ϕ iscomputed via a functional fine-tuning unit, and is encoded with a ϕlossless compression scheme.

FIG. 110 shows an example of an AI-based compression pipeline withfunctional fine-tuning, using a hyper-prior HP to represent theadditional parameters ϕ. An integer-valued hyper-parameter {circumflexover (z)} is found on a per-image basis, which is encoded into thebitstream. The parameter {circumflex over (z)} is used to parameterizethe additional parameter ϕ. The decoder D uses ϕ as an additionalparameter.

FIG. 111 shows an example of a channel-wise fully connectedconvolutional network. Network layers (convolutional operations) proceedfrom top to bottom in the diagram. The output of each layer depends onall previous channels.

FIG. 112 shows an example of a convolutional network with a sparsenetwork path. A mask (on the right-hand side) has been applied to thefully-connected convolutional weights (left-hand side) on a per-channelbasis. Each layer has a masked convolution (bottom) with output channelsthat do not depend on all previous channels.

FIG. 113 shows an example high-level overview of a neural compressionpipeline with encoder-decoder modules. Given the input data, the encoderspends encoding time producing a bitstream. Decoding time is spent bythe decoder to decode the bitstream to produce the output data, where,typically, the model is trained to minimise a trade-off between thebitstream size and the distortion between the output data and inputdata. The total runtime of the encoding-decoding pipeline is theencoding time+decoding time.

FIG. 114 shows examples relating to modelling capacity of linear andnonlinear functions.

FIG. 115 shows an example of interleaving of convolutional and nonlinearactivation layers for the decoder, as is typically employed in learnedimage compression.

FIG. 116 shows an example outline of the relationship between runtimeand modelling capacity of linear models and neural networks.

FIG. 117 shows example nonlinear activation functions. (a) Visualisationof ReLU. (b) Visualisation of Leaky ReLU. (c) Visualisation of Tanh. (d)Visualisation of Swish.

FIG. 118 shows an example outline of the relationship between runtimeand modelling capacity of linear models, neural networks and a proposedinnovation, which may be referred to as KNet.

FIG. 119 shows an example visualisation of a composition between twoconvolution operations, f and g, with convolution kernels W_(f) andW_(g) respectively, which encapsulates the composite convolutionoperation h with convolution kernel Wh.

FIGS. 120A and 120B show schematics of an example training configurationof a KNet-based compressive autoencoder, where each KNet modulecompresses and decompresses meta-information regarding the activationkernels Ki in the decoder.

FIGS. 121A and 121B show schematics of an example inferenceconfiguration of a KNet-based compressive autoencoder. The encoding sidedemonstrates input data x being deconstructed into bitstreams that areencoded and thereafter transmitted. The decoding side details thereconstruction of the original input data from the obtained bitstreams,with the output of the KNet modules being composed together with thedecoder convolution weight kernels and biases to form a single compositeconvolution operation, D_(k). Note how the decoding side has much lowercomplexity relative to the encoding side.

FIG. 122 shows an example structure of an autoencoder without ahyperprior. The model is optimised for the latent entropy parameters Oydirectly during training.

FIG. 123 shows an example structure of an autoencoder with a hyperprior,where hyperlatents ‘z’ encodes information regarding the latent entropyparameters ϕ_(y). The model optimises over the parameters of thehyperencoder and hyperdecoder, as well as hyperlatent entropy parametersϕ_(z).

FIG. 124 shows an example structure of an autoencoder with a hyperpriorand a hyperhyperprior, where hyperhyperlatents ‘w’ encodes informationregarding the latent entropy parameters ϕ_(z), which in turn allows forthe encoding/decoding of the hyperlatents ‘z’. The model optimises overthe parameters of all relevant encoder/decoder modules, as well ashyperhyperlatent entropy parameters ϕ_(w). Note that this hierarchicalstructure of hyperpriors can be recursively applied without theoreticallimitations.

DETAILED DESCRIPTION Technology Overview

We provide a high level overview of our artificial intelligence(AI)-based (e.g. image and/or video) compression technology.

In general, compression can be lossless, or lossy. In losslesscompression, and in lossy compression, the file size is reduced. Thefile size is sometimes referred to as the “rate”.

But in lossy compression, it is possible to change what is input. Theoutput image {circumflex over (x)} after reconstruction of a bitstreamrelating to a compressed image is not the same as the input image x. Thefact that the output image {circumflex over (x)} may differ from theinput image x is represented by the hat over the “x”. The differencebetween x and {circumflex over (x)} may be referred to as “distortion”,or “a difference in image quality”. Lossy compression may becharacterized by the “output quality”, or “distortion”.

Although our pipeline may contain some lossless compression, overall thepipeline uses lossy compression.

Usually, as the rate goes up, the distortion goes down. A relationbetween these quantities for a given compression scheme is called the“rate-distortion equation”. For example, a goal in improving compressiontechnology is to obtain reduced distortion, for a fixed size of acompressed file, which would provide an improved rate-distortionequation. For example, the distortion can be measured using the meansquare error (MSE) between the pixels of x and {circumflex over (x)},but there are many other ways of measuring distortion, as will be clearto the person skilled in the art. Known compression and decompressionschemes include for example, JPEG, JPEG2000, AVC, HEVC, AVI.

Our approach includes using deep learning and AI to provide an improvedcompression and decompression scheme, or improved compression anddecompression schemes.

In an example of an artificial intelligence (AI)-based compressionprocess, an input image x is provided. There is provided a neuralnetwork characterized by a function E( . . . ) which encodes the inputimage x. This neural network E( . . . ) produces a latentrepresentation, which we call y. The latent representation is quantizedto provide ŷ, a quantized latent. The quantized latent goes to anotherneural network characterized by a function D( . . . ) which is adecoder. The decoder provides an output image, which we call {circumflexover (x)}. The quantized latent ŷ is entropy-encoded into a bitstream.

For example, the encoder is a library which is installed on a userdevice, e.g. laptop computer, desktop computer, smart phone. The encoderproduces the y latent, which is quantized to ŷ, which is entropy encodedto provide the bitstream, and the bitstream is sent over the internet toa recipient device. The recipient device entropy decodes the bitstreamto provide ŷ, and then uses the decoder which is a library installed ona recipient device (e.g. laptop computer, desktop computer, smart phone)to provide the output image {circumflex over (x)}.

E may be parametrized by a convolution matrix θ such that y=E_(θ)(x).

D may be parametrized by a convolution matrix Ω such that {circumflexover (x)}=D_(Ω)(ŷ).

We need to find a way to learn the parameters θ and Ω of the neuralnetworks.

The compression pipeline may be parametrized using a loss function L. Inan example, we use back-propagation of gradient descent of the lossfunction, using the chain rule, to update the weight parameters of θ andΩ of the neural networks using the gradients ∂L/∂w.

The loss function is the rate-distortion trade off. The distortionfunction is

(x, {circumflex over (x)}), which produces a value, which is the loss ofthe distortion

. The loss function can be used to back-propagate the gradient to trainthe neural networks.

So for example, we use an input image, we obtain a loss function, weperform a backwards propagation, and we train the neural networks. Thisis repeated for a training set of input images, until the pipeline istrained. The trained neural networks can then provide good qualityoutput images.

An example image training set is the KODAK image set (e.g. atwww.cs.albany.edu/˜xypan/research/snr/Kodak.html). An example imagetraining set is the IMAX image set. An example image training set is theImagenet dataset (e.g. at www.image-net.org/download). An example imagetraining set is the CLIC Training Dataset P (“professional”) and M(“mobile”) (e.g. at http://challenge.compression.cc/tasks/).

In an example, the production of the bitstream from y is losslesscompression.

Based on Shannon entropy in information theory, the minimum rate (whichcorresponds to the best possible lossless compression) is the sum fromi=1 to N of (p_(ŷ)(ŷ_(i))*log₂(p_(ŷ)(ŷ_(i)))) bits, where p_(ŷ) is theprobability of ŷ, for different discrete ŷ values ŷ_(i), where ŷ={ŷ₁, ŷ₂. . . ŷN}, where we know the probability distribution p. This is theminimum file size in bits for lossless compression of ŷ.

Various entropy encoding algorithms are known, e.g. rangeencoding/decoding, arithmetic encoding/decoding.

In an example, entropy coding EC uses ŷ and p_(ŷ) to provide thebitstream. In an example, entropy decoding ED takes the bitstream andp_(ŷ) and provides ŷ. This example coding/decoding process is lossless.

How can we get filesize in a differentiable way? We use Shannon entropy,or something similar to Shannon entropy. The expression for Shannonentropy is fully differentiable. A neural network needs a differentiableloss function. Shannon entropy is a theoretical minimum entropy value.The entropy coding we use may not reach the theoretical minimum value,but it is expected to reach close to the theoretical minimum value.

In the pipeline, the pipeline needs a loss that we can use for training,and the loss needs to resemble the rate-distortion trade off.

A loss which may be used for neural network training is Loss=

+λ*R, where

is the distortion function, k is a weighting factor, and R is the rateloss. R is related to entropy. Both

and R are differentiable functions.

There are some problems concerning the rate equation.

The Shannon entropy H gives us some minimum file size as a function of ŷand p_(ŷ) i.e. H(ŷ, p_(ŷ)). The problem is how can we know p_(ŷ), theprobability distribution of the input? Actually, we do not know p_(ŷ).So we have to approximate p_(ŷ). We use q_(ŷ) as an approximation top_(ŷ). Because we use q_(ŷ) instead of p_(ŷ), we are instead evaluatinga cross entropy rather than an entropy. The cross entropy CE(ŷ, q_(ŷ))gives us the minimum filesize for ŷ given the probability distributionq_(ŷ).

There is the relation

H(ŷ,p _(ŷ))=CE(ŷ,q _(ŷ))+KL(p _(ŷ) ∥q _(ŷ))

Where KL is the Kullback-Leibler divergence between p_(ŷ) and q_(ŷ). TheKL is zero, if p_(ŷ) and q_(ŷ) are identical.

In a perfect world we would use the Shannon entropy to train the rateequation, but that would mean knowing p_(ŷ), which we do not know. Weonly know q_(ŷ), which is an assumed distribution.

So to achieve small file compression sizes, we need q_(ŷ) to be as closeas possible to p_(ŷ). One category of our inventions relates to theq_(ŷ) we use.

In an example, we assume q_(ŷ) is a factorized parametric distribution.

One of our innovations is to make the assumptions about qv moreflexible. This can enable q_(ŷ) to better approximate p_(ŷ), therebyreducing the compressed filesize.

As an example, consider that p_(ŷ) is a multivariate normaldistribution, with a mean μ vector and a covariant matrix Σ. Σ has thesize N×N, where N is the number of pixels in the latent space. Assumingŷ with dimensions 1×12×512×512 (relating to images with e.g. 512×512pixels), then Σ has the size 2.5 million squared, which is about 5trillion, so therefore there are 5 trillion parameters in E we need toestimate. This is not computationally feasible. So, usually, assuming amultivariate normal distribution is not computationally feasible.

Let us consider p_(ŷ), which as we have argued is too complex to beknown exactly. This joint probability density function p(ŷ) can berepresented as a conditional probability function, as the second line ofthe equation below expresses.

p(ŷ) = p((ŷ₁ŷ₂…ŷ_(N)) = p(ŷ₁) * p(ŷ₂❘ŷ₁) * p(ŷ₃❘{ŷ₁, ŷ₂}) * …

Very often p(ŷ) is approximated by a factorized probability densityfunction

p(ŷ ₁)*p(ŷ ₂)*p(ŷ ₃)* . . . p(ŷ _(N))

The factorized probability density function is relatively easy tocalculate computationally. One of our approaches is to start with a qwhich is a factorized probability density function, and then we weakenthis condition so as to approach the conditional probability function,or the joint probability density function p(ŷ), to obtain smallercompressed filzesizes. This is one of the class of innovations that wehave.

Distortion functions

(x, {circumflex over (x)}), which correlate well with the human visionsystem, are hard to identify. There exist many candidate distortionfunctions, but typically these do not correlate well with the humanvision system, when considering a wide variety of possible distortions.

We want humans who view picture or video content on their devices, tohave a pleasing visual experience when viewing this content, for thesmallest possible file size transmitted to the devices. So we havefocused on providing improved distortion functions, which correlatebetter with the human vision system. Modern distortion functions veryoften contain a neural network, which transforms the input and theoutput into a perceptional space, before comparing the input and theoutput. The neural network can be a generative adversarial network (GAN)which performs some hallucination. There can also be some stabilization.It turns out it seems that humans evaluate image quality over densityfunctions. We try to get p({circumflex over (x)}) to match p(x), forexample using a generative method eg. a GAN.

Hallucinating is providing fine detail in an image, which can begenerated for the viewer, where all the fine, higher spatialfrequencies, detail does not need to be accurately transmitted, but someof the fine detail can be generated at the receiver end, given suitablecues for generating the fine details, where the cues are sent from thetransmitter.

How should the neural networks E( . . . ), D( . . . ) look like? What isthe architecture optimization for these neural networks? How do weoptimize performance of these neural networks, where performance relatesto filesize, distortion and runtime performance in real time? There aretrade offs between these goals. So for example if we increase the sizeof the neural networks, then distortion can be reduced, and/or filesizecan be reduced, but then runtime performance goes down, because biggerneural networks require more computational resources. Architectureoptimization for these neural networks makes computationally demandingneural networks run faster.

We have provided innovation with respect to the quantization function Q.The problem with a standard quantization function is that it has zerogradient, and this impedes training in a neural network environment,which relies on the back propagation of gradient descent of the lossfunction. Therefore we have provided custom gradient functions, whichallow the propagation of gradients, to permit neural network training.

We can perform post-processing which affects the output image. We caninclude in the bitstream additional information. This additionalinformation can be information about the convolution matrix Ω, where Dis parametrized by the convolution matrix Ω. The additional informationabout the convolution matrix Ω can be image-specific. An existingconvolution matrix can be updated with the additional information aboutthe convolution matrix Ω, and decoding is then performed using theupdated convolution matrix.

Another option is to fine tune the y, by using additional informationabout E. The additional information about E can be image-specific.

The entropy decoding process should have access to the same probabilitydistribution, if any, that was used in the entropy encoding process. Itis possible that there exists some probability distribution for theentropy encoding process that is also used for the entropy decodingprocess. This probability distribution may be one to which all users aregiven access; this probability distribution may be included in acompression library; this probability distribution may be included in adecompression library. It is also possible that the entropy encodingprocess produces a probability distribution that is also used for theentropy decoding process, where the entropy decoding process is givenaccess to the produced probability distribution. The entropy decodingprocess may be given access to the produced probability distribution bythe inclusion of parameters characterizing the produced probabilitydistribution in the bitstream. The produced probability distribution maybe an image-specific probability distribution.

FIG. 1 shows a schematic diagram of an artificial intelligence(AI)-based compression process, including encoding an input image xusing a neural network, and decoding using a neural network, to providean output image {circumflex over (x)}.

In an example of a layer in an encoder neural network, the layerincludes a convolution, a bias and an activation function. In anexample, four such layers are used.

In an example, we assume that q_(ŷ) is a factorized normal distribution,where y={y₁, y₂ . . . y_(N)}, and ŷ={ŷ₁, ŷ₂ . . . ŷ_(N)}. We assume eachŷ_(i)(i=1 to N) follows a normal distribution N e.g. with a mean p ofzero and a standard deviation σ of 1. We can define ŷ=Int(y−μ)+μ, whereInto is integer rounding.

The rate loss in the quantized latent space comes from, summing (Σ) fromi=1 to N,

Rate=(Σ log₂(q _(ŷ)(ŷ _(i))))/N=(ΣN(ŷ _(i)|μ=0,σ=1))/N

The output image {circumflex over (x)} can be sent to a discriminatornetwork, e.g. a GAN network, to provide scores, and the scores arecombined to provide a distortion loss.

We want to make the q_(ŷ) flexible so we can model the p_(ŷ) better, andclose the gap between the Shannon entropy and the cross entropy. We makethe q_(ŷ) more flexible by using meta information. We have anotherneural network on our y latent space which is a hyper encoder. We haveanother latent space called z, which is quantized to {circumflex over(z)}. Then we decode the z latent space into distribution parameterssuch as μ and α. These distribution parameters are used in the rateequation.

Now in the more flexible distribution, the rate loss is, summing (Σ)from i=1 to N,

Rate=(ΣN(ŷ _(i)|μ_(i),σ_(i)))/N

So we make the q more flexible, but the cost is that we must send metainformation. In this system, we have

bitstream_(ŷ) =EC(ŷ,q _(ŷ)(μ,σ))

ŷ=ED(bitstream_(ŷ) ,q _(ŷ)(μ,σ))

Here the z latent gets its own bitstream_({circumflex over (z)}) whichis sent with bitstream_(ŷ). The decoder then decodesbitstream_({circumflex over (z)}) first, then executes the hyperdecoder, to obtain the distribution parameters (μ, σ), then thedistribution parameters (μ, σ) are used with bitstream_(ŷ) to decode theŷ, which are then executed by the decoder to get the output image{circumflex over (x)}.

Although we now have to send bitstream_({circumflex over (z)}), theeffect of bitstream_({circumflex over (z)}) is that it makesbitstream_(ŷ) smaller, and the total of the new bitstream_(ŷ) andbitstream_({circumflex over (z)}) is smaller than bitstream_(ŷ) withoutthe use of the hyper encoder. This is a powerful method calledhyperprior, and it makes the entropy model more flexible by sending metainformation. The loss equation becomes

Loss=

(x,{circumflex over (x)})+λ₁ *R _(y)+λ₂ *R _(z)

It is possible further to use a hyper hyper encoder for z, optionallyand so on recursively, in more sophisticated approaches.

The entropy decoding process of the quantized z latent should haveaccess to the same probability distribution, if any, that was used inthe entropy encoding process of the quantized z latent. It is possiblethat there exists some probability distribution for the entropy encodingprocess of the quantized z latent that is also used for the entropydecoding process of the quantized z latent. This probabilitydistribution may be one to which all users are given access; thisprobability distribution may be included in a compression library; thisprobability distribution may be included in a decompression library. Itis also possible that the entropy encoding process of the quantized zlatent produces a probability distribution that is also used for theentropy decoding process of the quantized z latent, where the entropydecoding process of the quantized z latent is given access to theproduced probability distribution. The entropy decoding process of thequantized z latent may be given access to the produced probabilitydistribution by the inclusion of parameters characterizing the producedprobability distribution in the bitstream. The produced probabilitydistribution may be an image-specific probability distribution.

FIG. 2 shows a schematic diagram of an artificial intelligence(AI)-based compression process, including encoding an input image xusing a neural network, and decoding using a neural network, to providean output image {circumflex over (x)}, and in which there is provided ahyper encoder and a hyper decoder.

In a more sophisticated approach, the distortion function

(x, {circumflex over (x)}) has multiple contributions. The discriminatornetworks produce a generative loss L_(GEN). For example a VisualGeometry Group (VGG) network may be used to process x to provide m, andto process {circumflex over (x)} to provide {circumflex over (m)}, thena mean squared error (MSE) is provided using m and {circumflex over (m)}as inputs, to provide a perceptual loss. The MSE using x and {circumflexover (x)} as inputs, can also be calculated. The loss equation becomes

Loss=λ₁ *R _(y)+λ₂ *R _(z)+λ₃ *MSE(x,{circumflex over (x)})+λ₄ *L_(GEN)+λ₅ *VGG(x,{circumflex over (x)}),

where the first two terms in the summation are the rate loss, and wherethe final three terms in the summation are the distortion loss

(x, {circumflex over (x)}). Sometimes there can be additionalregularization losses, which are there as part of making trainingstable.

Notes re HyperPrior and HyperHyperPrior

Regarding a system or method not including a hyperprior, if we have a ylatent without a HyperPrior (i.e. without a third and a fourth network),the distribution over the y latent used for entropy coding is notthereby made flexible. The HyperPrior makes the distribution over the ylatent more flexible and thus reduces entropy/filesize. Why? Because wecan send y-distribution parameters via the HyperPrior. If we use aHyperPrior, we obtain a new, z, latent. This z latent has the sameproblem as the “old y latent” when there was no hyperprior, in that ithas no flexible distribution. However, as the dimensionality re zusually is smaller than re y, the issue is less severe.

We can apply the concept of the HyperPrior recursively and use aHyperHyperPrior on the z latent space of the HyperPrior. If we have a zlatent without a HyperHyperPrior (i.e. without a fifth and a sixthnetwork), the distribution over the z latent used for entropy coding isnot thereby made flexible. The HyperHyperPrior makes the distributionover the z latent more flexible and thus reduces entropy/filesize. Why?Because we can send z-distribution parameters via the HyperHyperPrior.If we use the HyperHyperPrior, we end up with a new w latent. This wlatent has the same problem as the “old z latent” when there was nohyperhyperprior, in that it has no flexible distribution. However, asthe dimensionality re w usually is smaller than re z, the issue is lesssevere. An example is shown in FIG. 124 .

The above-mentioned concept can be applied recursively. We can have asmany HyperPriors as desired, for instance: a HyperHyperPrior, aHyperHyperHyperPrior, a HyperHyperHyperHyperPrior, and so on.

Notes re Training

Regarding seeding the neural networks for training, all the neuralnetwork parameters can be randomized with standard methods (such asXavier Initialization). Typically, we find that satisfactory results areobtained with sufficiently small learning rates.

Note

It is to be understood that the arrangements referenced herein are onlyillustrative of the application for the principles of the presentinventions. Numerous modifications and alternative arrangements can bedevised without departing from the spirit and scope of the presentinventions. While the present inventions are shown in the drawings andfully described with particularity and detail in connection with what ispresently deemed to be the most practical and preferred examples of theinventions, it will be apparent to those of ordinary skill in the artthat numerous modifications can be made without departing from theprinciples and concepts of the inventions as set forth herein.

1. HVS Inspired Variable Loss Segmentation for Learnt Image & VideoCompression 1.1 Introduction

Within the domain of learnt image and video compression, progress may beessentially measured jointly by two orthogonal metrics: perceptualquality and the compression factor of images. Perceptual quality can behard to measure; a function for it may be completely intractable.Nevertheless, it is well known that the sensitivity of the human visualsystem (HVS) to different attributes in images, such as textures,colours and various objects, are different-humans are more likely to beable to identify an alteration performed to a human face compared to apatch of grass. By producing segments of images to which the HVS is moreor less sensitive we can therefore improve the overall perceptualexperience of the compressed media by optimising the learnt compressionpipeline to follow heuristics from the HVS. We provide a modificationsto the learnt compression pipeline that utilises a generic family ofsegmentation based approaches to allow the optimisation of the learntcompression network to more closely follow the heuristics of the HVS,achieving better perceptual quality at the same or at a highercompression factor.

Modern machine learning algorithms are optimised using a method calledstochastic gradient descent. This method allows us to update theparameters of our model to a user-specific, desired goal. The goal iscontrolled by defining a loss-function that the network uses forbackpropagation. Every parameter in the network is updated such that theloss is decreased as the network trains. In typical compression networksthe same loss

is applied to the entire image, see Equation (1.1).

1.1.1 Loss Function

The loss function within learnt compression can in its simplest form beconsidered to be composed of two different terms: one term that controlsthe distortion of the compressed image or video, D, and another termthat controls the size of the compressed media (rate) R which istypically measured as the number of bits required per pixel (bpp). Anuncompressed image requires 24 bpp, most compressed images are below 0.5bpp. The λ parameter controls the trade-off between the size of theimage and the compression distortions. For example, in the extreme casethat λ=10⁶, the value of R can become very large (lossless compression),since λD will be very large. In the other extreme λ=10⁻⁶, the networkwill be forced to learn such that R becomes very small (since AD isalready minuscule).

=R+ΔD  (1.1)

In the standard learnt compression pipelines for image and video,Equation (1.1) is applied to train the network:

is minimised. However a key question in the equation above is how thedistortion D is estimated. Almost universally, the distortion of themedia D, is computed in the same way across the entire image or video.Similarly, the constraint on the size R is computed the same for theentire image. Intuitively, it should be clear that some parts of theimage should be assigned more bits, and some regions of the image shouldbe prioritised in terms of image quality.

The reason for this intuition comes from the human visual system (HVS).It has been shown that humans are more susceptible to image degradations(such as compression artifacts) introduced in parts of the image thatare more visually sensitive to the HVS. For example, the degradation ofhuman faces or low frequency areas in the image are more noticeable tothe HVS, and is therefore more likely to reduce the perceptual qualityof the media. A mechanism of improving perceptual quality is thus tooptimise parts of the image with different losses. To do this, weprovide a generic modifications to the learnt compression pipelinepowered by image segmentation operations, to compute dynamic lossesoptimised for the HVS.

1.1.2 Image Segmentation

In this section, a short introduction to the meaning of imagesegmentation within the field of computer vision is provided.

In the field of computer vision, image segmentation is a process thatinvolves dividing a visual input into different segments based on sometype of image analysis. Segments represent object or parts of objects,and comprise sets or groups of pixels. Image segmentation is a method ofgrouping pixels of the input into larger components. In the computervision there are many different methods in which the segmentation may beperformed to generate a grouping of pixels. A non-exhaustive list isprovided below to provide examples:

-   -   1. Classification Based: the entire image is grouped into a        certain type, e.g. this is an image of a person, this is an        image of a dog, or this is an outdoors scene.    -   2. Object Detection Based: based on images detected and        identified in the image, bounding boxes can be drawn around each        object. Each bounding box around the identified object now        represents a segment.    -   3. Segmentation: segmentation here refers to the process of        identifying which pixels in the image belongs to a particular        class. There are two major types of segmentation:        -   (a) Semantic: classifies all pixels of an image into            different classes.        -   (b) Instance: for each object that is identified in an            image, the pixels that belong to each object are grouped            separately. This is different from semantic segmentation,            where all objects of a particular class (e.g. all cats) will            be assigned the same group. For instance segmentation, each            cat is assigned its own segment or group as in (C) in the            FIG. 3 , where each dog has its own segment.

The segmented images are typically produced by a neural network. Howeverfor the pipeline presented here, the segmentation operator can becompletely generic.

1.2 an Innovation 1.2.1 Image Segmentation for Perceptual Compression

An example of a generic pipeline is shown in FIG. 4 . There are twoseparate processes shown in the figure. Firstly, the segmentationoperation and transformation. This process segments the image using somemechanism and may optionally apply an additional transformation to thesegmented data. The segmented image and the output of the segmentedoperation is used as an input to the compression network. During thetraining of the learnt compression pipeline the loss function cantherefore be modified to take the segmentation input into consideration.

The loss function shown above in Equation (1.1) can therefore bemodified as follows:

$\begin{matrix}{\mathcal{L} = {\sum\limits_{i}^{n}{c_{i}\left( {R_{i} + {\lambda_{i}D_{i}}} \right)}}} & (1.2)\end{matrix}$

where n refers to the number of segments in the image, R_(i) is the ratefor a particular segment, D_(i) is the distortion for a particularsegment, λ_(i) is the Lagrange multiplier and ci a constant, for segmenti. This means that for each segment i in the image a different method ofcomputing rate R and distortion D can be applied. For example, thedistortion metric for texts may utilise an MSE loss, whereas for facesit utilises a mixture of perceptual and adversarial losses.

Furthermore, the computation of R_(i) means that each segment can have avariable rate. For example, assigning more bits to regions with highersensitivity for the HVS, such as the faces and texts, or any othersalient region in the image, will improve perceptual quality withoutincreasing the total number of bits required for the compressed media.

This generic pipeline has been exemplified with 4 different segmentationapproaches in the next section, however it extends to all types ofsegmentation, in addition to the 4 examples provided, such as clusteringbased segmentation, region-based segmentation, edge-detectionsegmentation, frequency based segmentation, any type of neural networkpowered segmentation approach, etc,.

1.2.2 Segmentation Module

The segmentation module in FIG. 4 is a generic component that groupspixels in the input based on some type of algorithm. Non-exhaustiveexamples of such algorithms were given in the introduction. Training ofthe segmentation module, if it is parameterised as a neural network, maybe performed separately or during the training of the compressionnetwork itself—referred to as end-to-end. End-to-end training of thesegmentation network together with the compression network may requireground truth labels for the desired segmentation output, or some type ofground truth label that can guide the segmentation module, whilst thecompression network is training simultaneously. The training follows thebi-level principle, meaning that gradients from the compression networkdo not affect the segmentation module training, and the segmentationnetwork gradients do not affect the compression network gradients.Therefore the end-to-end training of the segmentation and thecompression network can still be isolated separately in terms ofgradient influences. The training of the segmentation network in theend-to-end scheme can thus be visualised as in FIG. 9 (the usage ofinstance segmentation is only an example, and it may be trained for anytype of segmentation task), which replaces the Segmentation Module inFIG. 4 . In the bi-level training scheme, the segmentation network istrained, following this the compression network is trained using asegmentation mask from the segmentation module, as shown in Algorithm1.2.

Algorithm 1.1 Pseudocode that outlines the training of the compressionnetwork using the output from the segmentation operators. It assumes theexistence of 2 functions backpropagate and step. backpropagate will useback-propagation to compute gradients of all parameters with respect tothe loss, step performs an optimization step with the selectedoptimizer. Lastly the existence of a context Without Gradients thatensures gradients for operations within the context are not computed.Parameters: Segmentation Module: ƒ_(ϕ) Compression Network: ƒ_(θ)Compression Network Optimizer: opt_(ƒ) _(θ) Compression Loss Function:

_(C) Input image: x ϵ

 ^(H×W×C) Segmentation Network: Without Gradients: {circumflex over (x)}← ƒ_(ϕ)(x) Compression Network: {circumflex over (x)}_(s) ← ƒ_(θ)(x,{circumflex over (x)}_(s)) back propagate( 

_(C)({circumflex over (x)}, x, {circumflex over (x)}_(s))) step(opt_(ƒ)_(θ) )

Algorithm 1.2 Pseudocode that outlines the training of the compressionnetwork and the segmentation module in an end-to-end scenario. Itassumes the existence of 2 functions backpropagate and step.backpropagate will use back-propagation to compute gradients of allparameters with respect to the loss step performs an optimization stepwith the selected optimizer. Lastly the existence of a context WithoutGradients that ensures gradients for operations within the context arenot computed. Parameters: Segmentation Module: ƒ_(ϕ) Segmentation ModuleOptimizer: opt_(ƒ) _(ϕ) Compression Network: ƒ_(θ) Compression NetworkOptimizer: opt_(ƒ) _(θ) Compression Loss Function:

_(C) Segmentation Loss Function:

 _(s) Input image for compression: x ϵ

 ^(H×W×C) Input image for segmentation: x_(s) ϵ

 ^(H×W×C) Segmentation labels: y_(s) ϵ

 ^(H×W×C) Segmentation Network Training: {circumflex over (x)}_(s) ←ƒ_(ϕ) (x_(s)) back propagate( 

 _(s)({circumflex over (x)}_(s), y_(s))) step(opt _(ƒ) _(ϕ) )Compression Network: Without Gradients: {circumflex over (x)}_(s) ←ƒ_(ϕ) (x) {circumflex over (x)} ← ƒ_(θ) (x, {circumflex over (x)}_(s))backpropagate ( 

 _(C)({circumflex over (x)}, x, {circumflex over (x)}_(s))) step(opt_(ƒ)_(θ) )

1.2.3 Segmentation Examples

In FIG. 5 the segmentation operator uses the instance segmentationmethod, and in the FIGS. 6, 7, 8 the semantic, object and block basedapproaches are used. In general, any type of segmentation approach isapplicable to this pipeline.

Frequency-Based Transformation

It is well known that the HVS is more sensitive to changes in lowfrequency regions, such as uniform areas, compared to changes in highfrequency regions such as in patches of grass. In general, for mostimages the majority of high frequencies can be removed within anynoticeable difference in the image. Based on this intuition, it istherefore possible to create Just Noticeable Difference (JND) masks,based on segments of frequencies in the image, that indicate which partsof the image are most likely to be noticed by the HVS if distorted. Onemethod by which the masks may be computed is using Algorithm 1.3.

Based on Algorithm 1.3, an example method of producing JND masks, is touse the Discrete Cosine Transform (DCT) and Inverse DCT on the segmentsfrom the segmentation operator. The JND masks may then be provided asinput into the compression pipeline, for example, as shown in FIG. 4 .This segmentation approach allows distortion metrics to be selected tobetter match the HVS heuristics. For example, an adversarial GAN lossmay be applied for high frequency regions, and an MSE for low frequencyareas. The method described above that utilises the DCT is a naiveapproach to produce JND masks; this method is not restricted to thatparticular realization of Algorithm 1.3 below.

Algorithm 1.3 Pseudocode for computation of JND masks Parameters:Segmentation Operator: ƒ_(ϕ) IND Transform: jnd, ƒ :

 ^(N →)

^( N) Input image: x ϵ

^(H×W×C) JND Heatmaps: x_(b), m ← ƒ_(ϕ) (x) x_(jnd) ← jnd(x_(b))

1.2.4 Loss Function Classifier

A different type of segmentation approach that more directly targets theHVS is to utilise a number of different learnt compression pipelineswith distinctly different distortion metrics applied on the samesegmentations of the images. Once trained, human raters are asked in a2AFC selection procedure to indicate which patch from the trainedcompression pipelines produces the perceptually most pleasing imagepatch. For example, if there are 4 distortion metrics {d₀, d₁, d₂, d₃},there will be 4 predicted patches, {{circumflex over (x)}₀, {circumflexover (x)}₁, {circumflex over (x)}₂, {circumflex over (x)}₃}, one fromeach metric trained with the different distortion losses {L₀, L₁, L₂,L₃}, as shown in FIGS. 10 and 12 . Given a large number of human ratersand large number of image patches, a large dataset with image patchesand labels is then formed, where the label indicates which distortionmetric is preferred by the HVS for the patch. A neural networkclassifier is then trained to predict the optimal distortion metric foreach patch of the predicted outputs of the learnt compression pipeline,as shown in FIG. 11 for example. Once the classifier has been trained,it can be used to predict optimal distortion losses for individual imagesegments as shown in FIG. 12 for example.

1.2.5 Colour-Space Segmentation

The image segmentation approaches discussed above segments pixels acrossthe channels within the RGB colour space. However an alternativecolour-space representation is known as YCbCr, where Y represents theluma component of the image; CbCr the chroma information of the image.Given a particular distortion metric that only operates on a certainportion of the colour space, a natural segmentation of the totaldistortion loss of the network is then an expectation of some number ofdistortion metrics across the colour space, where each component of thecolour space may have a different distortion metric. That is, forexample, some particular set of distortion metrics may operate on theluma component, whereas some other set may operate on the chroma part.The loss operating on each component has been optimized for the colourspace in which it operates (or may not even be applicable outside thegiven space).

That is, the loss function may be re-written as below

$\begin{matrix}{\mathcal{L} = {{\sum\limits_{i}^{n}R_{i}} + {\lambda_{i}D_{i}}}} & (1.3)\end{matrix}$

where i is now an index into the colour space, where R_(i), λ_(i) andD_(i) refer to colour-space specific metrics.

The idea of colour-space segmentation is not limited to RGB and YCbCr,and is easily applied to any colour-space, such as CMYK, scRGB, CIE RGB,YPbPr, xvYCC, HSV, HSB, HSL, HLS, HSI, CIEXYZ, sRGB, ICtCp, CIELUV,CIEUVW, CIELAB, etc, as shown in FIG. 13 for example.

1.2.6 Concepts

-   -   1. A classifier trained to identify optimal distortion losses        for image or video segments used for to train a learnt image and        video compression pipeline    -   2. Segmentation operator (such as, but not limited to, instance,        classification, semantic, object detection) applied or trained        in a bi-level fashion with a learnt compression pipeline for        images and video to selectively apply losses for each segment        during training of the compression network    -   3. Colour-space segmentation to dynamically apply different        losses to different segments of the colour-space

2. Flexible Entropy Modelling of Latent Distributions 2.1 Introduction

Accurate modelling of the true latent distribution is instrumental forminimising the rate term in a dual rate-distortion optimisationobjective. A prior distribution imposed on the latent space, the entropymodel, optimises over its assigned parameter space to match itsunderlying distribution, which in turn lowers encoding costs. Thus, theparameter space must be sufficiently flexible in order to properly modelthe latent distribution; here we provide a range of various methods toencourage flexibility in the entropy model.

In AI-based data compression, an autoencoder is a class of neuralnetwork whose parameters are tuned, in training, primarily to performthe following two tasks jointly:

-   -   1. Find a compressed latent representation of the input data        such that the description of that representation is as short as        possible;    -   2. Given the latent representation of the data, transform it        back into its input either exactly (lossless compression) or        approximately (lossy compression).

Here we assume a lossy compression pipeline, however it should be notedthat many concepts presented here are also applicable in losslesscompression. The aforementioned tasks form the framework of a jointoptimisation problem of two loss terms commonly found in compressionproblems, namely the minimisation of metrics representing rate, R(·),and distortion, D(·), respectively. The rate-distortion minimisationobjective can mathematically be expressed in form of a weighted sumdenoted by

(·)

$\begin{matrix}{{\min\limits_{x,\theta}{\mathcal{L}\left( {x,\theta} \right)}} = {{R\left( {x,\theta} \right)} + {\lambda{D\left( {x,\theta} \right)}}}} & (2.1)\end{matrix}$

where x is the input data, θ is the network parameters and λ is aweighting factor that controls the rate-distortion balance. The rateloss is directly controlled by the ability of the network to accuratelymodel the distribution of the latent representations of the input data,which brings forward the notion of entropy modelling which shall beoutlined and justified in detail. In theory, the more accurately theentropy model matches the true latent distribution, the lower the rateterm is. Note that the distortion term is also influenced indirectly asa result from the joint rate-distortion minimisation objective. However,for the sake of clarity, we will largely ignore the distortion term orany consequential impact of it from minimising the rate here.

The focus here is to

-   -   (a) introduce and explain the theory and practical        implementation of entropy modelling of the latent distribution        in AI-based data compression;    -   (b) describe and exemplify a number of novel methods and        technologies that introduces additional flexibility in entropy        modelling of the latent distribution in AI-based data        compression.

2.2 Preliminaries

Below follows a detailed section on mathematical preliminaries that willact as a helpful guide. One common conventionality adopted is that thearray data format of a quantity (scalars, vectors, matrices, etc.) isindependent of the data itself. This means that if a quantity isfundamentally one-dimensional, such as a vector x of length N, then itcan either be represented directly as a vector format x∈

^(N) or as an array (or tensor) format x∈

^(H×W×3) (where N=H×W×3). In other words, no matter how we organise xinto different data structures, the fundamental variables containedwithin a particular instance of x are not mutated.

The following is a list of how various quantity types encountered withinthe text body are conventionally denoted:

-   -   Scalars are 0-dimensional and denoted in italic typeface, both        in lowercase and uppercase Roman or Greek letters. They        typically comprise of individual elements, constants, indices,        counts, eigenvalues and other single numbers. Example notation:        i, N, λ    -   Vectors are 1-dimensional and denoted in boldface and lowercase        Roman or Greek letters. They typically comprise of inputs,        biases, feature maps, latents, eigenvectors and other quantities        whose intervariable relationships are not explicitly        represented. Example notation: x, μ, ŷ, σ    -   Matrices are 2-dimensional and denoted in boldface and uppercase        Roman or Greek letters. They typically comprise of weight        kernels, covariances, correlations, Jacobians, eigenbases and        other quantities that explicitly model intervariable        relationships. Example notation: W, B, Σ, J_(ƒ)    -   Parameters are a set of arbitrarily grouped vector and/or matrix        quantities that encompasses for example all the weight matrices        and biases vectors of a network, or the parametrisation of a        probability model which could consist of a mean vector and a        covariance matrix. They will conventionally be denoted in the        text by either of the Greek letters θ (typically network        parameters), ϕ (typically probability model parameters) and ψ (a        placeholder parameter).

The rest of the symbols commonly encountered relate to functions,operations or mappings, which follows the standardised form as detailedbelow:

-   -   Functions will typically have enclosing brackets indicating the        input, which evaluates to a predefined output. Most generically,        this could look like ƒ_(enc)(·) or R(·) where the dot denotes an        arbitrary input.    -   Probability density functions (PDFs) are commonly (but not        always!) denoted as lowercase p with a subscript denoting the        distributed variable, and describes the probability density of a        continuous variable. It usually belongs to a certain        distribution type that is typically predefined in the text. For        instance, if {tilde over (y)}_(i) follows a univariate normal        distribution, we could write {tilde over (y)}_(i)˜        (μ, σ); then, p_({tilde over (y)}i)({tilde over (y)}_(i); ϕ)        would represent the PDF of a univariate normal distribution,        implicitly parametrised by ϕ=(μ, σ).    -   Probability mass functions (PMFs) are analogous to probability        density functions, but describe the probability mass (or just        probability) of a discrete variable. They are commonly denoted        as uppercase P, but not always, with a subscript denoting the        distributed variable.    -   Expectations are commonly denoted as        _(x˜p) _(x) [⋅]. They refer to the average value of the quantity        enclosed within the brackets across all instances x in the        distribution p_(x). If the expectation is taken across a valid        probability distribution, like in this case, then the following        is equivalent:        _(x˜p) _(x) [ƒ(x)]=∫_(x)p_(x)(x_(i))ƒ(x_(i))dx_(i) (for        continuous distributions) and        _(x˜p) _(x) [ƒ(x)]=Σ_(xi)P_(x)(x_(i))ƒ(x_(i)) (for discrete        distributions).    -   Other commonly seen symbols include rounding (up or down) to        nearest integer └⋅┐, flooring (round down to nearest integer)        operation └⋅┘, flooring (round up to nearest integer) operation        ┌⋅┐, the convolution operator *, the point-wise (Hadamard)        multiplication operator ⊙ and point-wise division operator/

The standard convention for index subscripts is the following: to indexan individual element in a vector x, the subscript i is used for thecolumn index (e.g. x_(i)). To index an individual element in a matrix Σ,the subscripts i, j and lowercase letters are used for the row andcolumn index, respectively (e.g. σ_(i,j)). Quantities with bracketedsuperscripts are associated with additional partitioning or groupings ofvectors/matrices, such as latent space partitioning (often with index[b]) or base distribution component of a mixture model (often with index[k]). For example, indexing can look like y^([b]), ∀b∈{1, . . . , B} andμ^([k]), ∀k∈{1, . . . , K}.

2.3 Entropy Modelling of Latent Distribution

This section serves to inform about the fundamentals of rateminimisation through entropy modelling of the latent distribution. Wedescribe the various components in the network that this affects, whythese components are necessary and the theory that underpins them.Demonstrative examples are also included as a guide.

2.3.1 Components of the Autoencoder

The autoencoder for AI-based data compression, in a basic form, includesfour main components:

-   -   1. Encoder y=ƒ_(enc)(x): analysis transform of input vector x to        latent vector y    -   2. Quantisation ŷ=Q(y): discretisation process of binning        continuous latents into discrete centroids    -   3. Entropy model P_(ŷ)(ŷ; ϕ): prior distribution on the true        quantised latent distribution    -   4. Decoder {circumflex over (x)}=ƒ_(dec)(ŷ): synthesis transform        of quantised latents ŷ to approximate input vector {circumflex        over (x)}

FIG. 14 shows an example of the forward flow of data through thecomponents. Here, we mainly focus on the entropy model and themechanisms that take place there. However, to facilitate understandingof the ensuing discussions around that topic, the next paragraphs willdescribe how these components relate to each other and how that givesrise to the so called latent space, on which the entropy model operates.The exact details regarding network architecture and hyperparameterselection are abstracted away.

The encoder transforms an N-dimensional input vector x to anM-dimensional latent vector y, hence the encoder transforms a datainstance from input space to latent space (also called “bottleneck”)ƒ_(enc):

^(N)→

^(M). M is generally smaller than N, although this is by no meansnecessary. The latent vector, or just the latents, acts as the transformcoefficient which carries the source signal of the input data. Hence,the information in the data transmission emanates from the latent space.

As produced by the encoder, the latents generally comprise continuousfloating point values. However, the transmission of floating pointvalues directly is costly, since the idea of entropy coding does notlend itself well to continuous data. Hence, one technique is todiscretise the latent space in a process called quantisation Q:

^(M)→

_(Q) ^(M) (where

_(Q) ^(M) denotes the quantised M-dimensional vector space,

_(Q) ^(M)⊂

^(M)). During quantisation, latents are clustered into predeterminedbins according to their value, and mapped to a fixed centroid of thatbin. One way of doing this is by rounding the latents to the nearestinteger value. The overall effect is that the set of possible values forthe latents is reduced significantly which allows for shorterdescriptors, but this also curbs expressiveness due to the irrecoverableinformation loss. We normally denote quantities that have undergonequantisation with a hat symbol, such as ŷ.

Once the latents are discretised, we can encode them into a bitstream.This process is called entropy coding which is a lossless encodingscheme; examples include arithmetic/range coding and Huffman coding. Theentropy code comprises a codebook which uniquely maps each symbol (suchas an integer value) to a binary codeword (comprised by bits, so 0s and1s). These codewords are uniquely decodable, which essentially means ina continuous stream of binary codewords, there exists no ambiguity ofthe interpretation of each codeword. The optimal entropy code has acodebook that produces the shortest bitstream. This can be done byassigning the shorter codewords to the symbols with high probability, inthe sense that we would transmit those symbols more times than lessprobable symbols. However, this requires knowing the probabilitydistribution in advance.

This is where the entropy model comes in. It defines a prior probabilitydistribution over the quantised latent space P_(ŷ)(ŷ; ϕ), parametrisedby the entropy parameters ϕ. The prior aims to model the true quantisedlatent distribution, also called the marginal distribution m(ŷ) whicharises from what actually gets outputted by the encoder and quantisationsteps, as closely as possible. The marginal is an unknown distribution;hence, the codebook in our entropy code is determined by the priordistribution whose parameters we can optimise for during training. Thecloser the prior models the marginal, the more optimal our entropy codemapping becomes which results in lower bitrates.

It is assumed that the codebook defined by the entropy model exists onboth sides of the transmission channel. Under this condition, thetransmitter can map a quantised latent vector into a bitstream, send itacross the channel. The receiver can then decode the quantised latentvector from the bitstream losslessly, pass it through the decoder whichtransforms it into an approximation of the input vector {circumflex over(x)},

_(Q) ^(M)→

^(N).

2.3.2 Ensuring Differentiability During Network Training

What has been presented thus far is how a typical compression pipelinewould work in practical application. However, during gradientdescent-based training, we must ensure differentiability throughout theentire autoencoder in order for the loss gradients to backpropagate andupdate the network parameters. However, essential steps such asquantisation and entropy coding are usually non-differentiable and breakthe flow of gradient information during backpropagation. Therefore, anautoencoder often trains with proxy operations that mimic the prohibitedoperations whilst ensuring differentiability throughout the network.Specifically, we need to estimate the rate given our entropy model andsimulate the effects of quantisation in a differentiable manner. Oncethe network has finished training, non-differentiable operations can bepermitted for inference and real-life application.

Hence, we need to pay attention to the different “modes” of the networkwhen it processes data; the particular “mode” of the network governs howcertain operations behave within the network (see Table 2.1):

-   -   Training: as batches of training data are inputted through the        network, the rate and distortion loss metrics evaluated on the        output spur gradient signals that backpropagate through the        network and update its parameters accordingly. This is referred        to as a training pass. In order for the gradients to propagate        through the network, all operations must be differentiable.    -   Inference: normally refers to validation or test passes. During        inference, data is inputted through the network and the rate and        distortion loss metrics are evaluated. However, no        backpropagation or parameter updates occurs. Thus,        non-differentiable operations pose no issue.    -   Deployment: refers to the neural network being put into use in        practical, real-life application. The loss metric is        disregarded, and the encode pass and decode pass are now        different and must be separated. The former inputs the original        data into the encoder and produces an actual bitstream from the        encoded latents through entropy coding. The latter admits this        bitstream, decodes the latents through the reverse entropy        coding process, and generates the reconstructed data from the        decoder.

FIG. 15 shows an example of a flow diagram of a typical autoencoder atnetwork training mode.

TABLE 2.1 Depending on the mode of the neural network, differentimplementations of certain operations are used. Network modeQuantisation Rate evaluation Training noise approximation cross-entropyestimation Inference rounding cross-entropy estimation Deploymentrounding entropy coding

Estimating Rate with Cross-Entropy

Information theory states that given a PMF M_(X)(x) describing theprobability distribution of the discrete random variable X, the shortestaverage message length that unambiguously relays information about asample x_(i) drawn from it is equal to the Shannon entropy of thatdistribution. The Shannon entropy is defined as

$\begin{matrix}{{{H\left( M_{X} \right)} \equiv {- {\sum\limits_{x_{i}}{{M_{X}\left( x_{i} \right)}\log_{b}{M_{X}\left( x_{i} \right)}}}}} = {- {_{x_{i}\sim M_{X}}\left\lbrack {\log_{b}{M_{X}\left( x_{i} \right)}} \right\rbrack}}} & (2.2)\end{matrix}$

where b denotes the base of the logarithm. If b=2, the unit of thisentropy is bits. This is where the notion of the optimal codebook inentropy coding, as well as the term entropy modelling, are derived from.

However, suppose we do not know the exact probability distribution ofstates (M_(X) is unknown), but build our codebook with another knowndistribution P_(x)(x), the average message length that unambiguouslyrelays information about a sample x_(i) drawn from M_(X) is then equalto the cross-entropy of the distribution P_(X) over M_(X):

$\begin{matrix}{{{H\left( {M_{X},P_{X}} \right)} \equiv {- {\underset{x_{i}}{\Sigma}{{M_{X}\left( x_{i} \right)}\log_{b}{P_{X}\left( x_{i} \right)}}}}} = {- {{\mathbb{E}}_{x_{i}\sim M_{X}}\left\lbrack {\log_{b}{P_{X}\left( x_{i} \right)}} \right\rbrack}}} & (2.3)\end{matrix}$

The cross-entropy can be rephrased in terms of the Kullback-Leibler (KL)divergence, which is always nonnegative and can be interpreted asmeasuring how different two distributions are to one and another:

H(M _(X) ,P _(X))≡H(M _(X))+D _(KL)(M _(X) ∥P _(X))  (2.4)

From this, it is evident that the cross-entropy term is lower bounded bythe Shannon entropy. If the cross-entropy reduces as a consequence ofconfiguring P_(X), the KL divergence reduces commensurately, implyingthat P_(X) is becoming more similar to M_(X). It is now clear what themotivation for learning a prior distribution P_(ŷ) for the quantisedlatent space that ideally should match the unknown marginal distributionm_(ŷ). The cross-entropy of P_(ŷ) over m_(ŷ) acts as a theoreticalmeasure for the achieved bitrate if we were to perform entropy codingwith it, which is differentiable since it only depends on a logarithmoperator and expectation operation! Hence, we can define our rate loss Rby estimating the cross-entropy of the prior over the marginal:

R=H(m _(ŷ) ,P _(ŷ))=

_(ŷ˜m)[log₂ P _(ŷ)(ŷ)]  (2.5)

Effects of Quantisation on Entropy Modelling

Note that quantisation, whilst closely related to the entropy model, isa significant separate topic of its own. However, since quantisationinfluences certain aspects of entropy modelling, it is thereforeimportant to briefly discuss the topic here. Specifically, they relateto

-   -   (a) differentiability of the assumed probability model;    -   (b) differentiability of the quantisation operation.

So far, we have only considered discrete probability distributions asentropy models. This is due to quantisation, which discretises thecontinuous vector space for the (raw) latents y. However, discretedistributions do not lend themselves well to gradient-based approachesdue to their discontinuities. It is also possible to pick a continuousdistribution as a prior, with the PDF p_(y)(y; ϕ) that is parametrisedby ϕ, on the latent space. We can simply account for quantisation in theentropy model by evaluating probability masses over p_(y) by integratingover a zero-centred integration region Ω for each quantisation interval.For example, for a single variable ŷ_(i) (so in 1-D), the PMF can bedefined as

P _(ŷi)(ŷ _(i))=∫_(ŷi+ai) ^(ŷi+bi) P _(yi)(y)dy,∀ŷ _(i) ∈

_(Q)  (2.6)

where the integration region per quantisation bin is defined by itsbounds Ω_(i)=[a_(i), b_(i)]. In other words, the effect of quantisationon entropy modelling is that probability masses for each quantised statemust be computed (for example, see FIG. 16 ) For continuousdistributions with a closed-form expression for its cumulative densityfunction (CDF), F_(y) _(i) , Equation (2.6) is simplified as:

P _(y) _(i) (ŷ _(i))=F _(y) _(i) (ŷ _(i) +b _(i))−F _(y) _(i) (ŷ _(i) +a_(i)),∀ŷ _(i)∈

_(Q)  (2.7)

Example: Suppose the entropy model p_(y) _(i) comprises a univariatenormal distribution per variable as prior distribution on the latents,y_(i)˜

(μ_(i), σ_(i)). Its CDF is denoted by

${{F_{yi}\left( y_{i} \right)} = {\Phi\left( \frac{y_{i} - \mu_{i}}{\sigma_{i}} \right)}},$

where Φ(·) is the CDF of the standard normal distribution. Then,assuming regular integer-sized quantisation bins

$\left( {{so}{\Omega_{i} = \left\lbrack {{- \frac{1}{2}},\frac{1}{2}} \right\rbrack}} \right),$

we calculate the probability masses as follows:

${{P_{\overset{\hat{}}{y}i}\left( {\overset{\hat{}}{y}}_{i} \right)} = {{\Phi\left( \frac{{\overset{\hat{}}{y}}_{i} + \frac{1}{2} - \mu_{i}}{\sigma_{i}} \right)} - {\Phi\left( \frac{{\overset{\hat{}}{y}}_{i} - \frac{1}{2} - \mu_{i}}{\sigma_{i}} \right)}}},{\forall{{\overset{\hat{}}{y}}_{i} \in {\mathbb{R}}_{Q}}}$

The second point becomes slightly more involved. Here we will notdiscuss differentiable quantisation in more detail than necessary. Themain discussion point revolve around perturbing y∈

^(M) with additive noise to simulate the effects of quantisation (thereexist other differentiable quantisation methods which are known to theskilled person). Certain quantisation operations can be seen as havingsimilar effects. Hence, when differentiability is imperative, we cansubstitute actual quantisation with noise quantisation {tilde over (Q)}:y

{tilde over (y)}

{tilde over (Q)}(y)={tilde over (y)}=y+∈ _(Q)  (2.8)

where ∈_(Q) is drawn from any random noise source distribution Θ,ideally similarly bounded as the perturbation emerging from actualquantisation though this is not a necessity. The simulated noise sourceΘ could theoretically have different distribution characteristics fromthe true quantisation perturbation source (it could for instance beUniform, Gaussian or Laplacian distributed).

One key feature with this type of quantisation simulation is the effectit has on the (continuous) prior distribution. Unlike actualquantisation, {tilde over (Q)} maps a vector from

^(M) to

^(M), and not to the centroid of some quantisation bin. If we select therandom noise source to be a uniform distribution with a width equal tothe quantisation interval, the distribution of {tilde over (y)},p_({tilde over (y)})({tilde over (y)}) becomes a continuous relaxationof the probability mass formulation (Equation (2.6)). This can beunderstood by viewing the prior distribution as being convolved with theuniform distribution, which acts as a box-car smoothing filter (seerectangular box in FIG. 16 , for example). In fact, this also works forany Θ, such that

p _({tilde over (y)})({tilde over (y)})=(p _(y) *P _(∈) _(Q) )({tildeover (y)})  (2.9)

Example: Suppose that the actual quantisation operation is rounding tothe nearest integer, Q (y)=└y┐. This can be seen as adding ahalf-integer bounded noise vector

$\epsilon_{Q} \in {\left\lbrack {{- \frac{1}{2}},\ \frac{1}{2}} \right\rbrack^{M}.}$

Hence, we can simulate the quantisation perturbation in training byadding a uniformly distributed random noise vector ∈_(Q), each elementsampled from

$\epsilon_{Q,i} \sim {{\mathcal{U}\left( {{- \frac{1}{2}},\frac{1}{2}} \right)}.}$

This results in the continuously relaxed probability model

${p_{\overset{\sim}{y}}\left( \overset{\sim}{y} \right)} = {\left( {p_{y}*{\mathcal{U}\ \left( {{- \frac{1}{2}},\ \frac{1}{2}} \right)}} \right)\left( \overset{\sim}{y} \right)}$

2.3.3 Properties of Latent Distribution

The true latent distribution of y∈

^(M) can be expressed, without loss of generality, as a joint(multivariate) probability distribution with conditionally dependentvariables

p(y)≡p(Y ₁ ,Y ₂ , . . . ,Y _(M))  (2.10)

which models the probability density over all sets of realisations of y.Therefore, it captures how each variable is distributed independently ofthe others as well as any intervariable dependencies between pairs ofvariables. However, since M is often very large, modelling intervariabledependencies between M variables would require enormous computationalresources.

Another way to phrase a joint distribution is to evaluate the product ofconditional distributions of each individual variable, given allprevious variables:

P(Y ₁ ,y ₂ , . . . ,y _(M))=P(Y ₁)·P(y ₂ |y ₁)·P(y ₃ |Y ₁ ,y ₂)·. . .·P(Y _(M) |Y ₁ , . . . ,y _(M- 1))  (2.11)

We can model each conditional distribution p(y_(i)|y₁, . . . , y_(i−1))using a so-called conditional or context model ƒ_(context) (·), which isa function mapping that takes in the previous variables and outputs theentropy parameters of the current variable: ϕ_(i)=ƒ_(context)({y₁, . . ., y_(i−1)}). In practice, ϕ_(i) would be evaluated one by one, whichimplies a serial encoding and decoding process. Assuming idealparametrisation of the conditional distributions (which is rarely thecase), we would be able to model the joint distribution perfectly.Unfortunately, serial encoding and decoding processes are very slow toexecute, especially over a large number of dimensions.

Thus, in order to ensure realistic runtime of the operations, it ispossible to ignore the conditioned variables, and model the latentdistribution as a product of independent, univariate distributions

p(Y)=p(y ₁)·p(y ₂)·p(y ₃)·. . . ·P(Y _(M))  (2.12)

where each distribution p(y_(i)) can be parametrised by entropyparameters ϕ_(i). This type of entropy model is called factorised prior,since we can evaluate the factors (probability masses) for each variableindividually (i.e. the joint is factorisable). The entropy parameters ϕcan be included with the network parameters that are optimised overduring training, for which the termfully factorised is often used. Thedistribution type may be either parametric or non-parametric, withpotentially multiple peaks and modes. See FIG. 17 for example.

AI-based data compression architectures may contain an additionalautoencoder module, termed a hypernetwork. A hyperencoder h_(enc)(·)compresses metainformation in the form of hyperlatents z analogously tothe main latents. Then, after quantisation, the hyperlatents aretransformed through a hyperdecoder h_(dec)(·) into instance-specificentropy parameters ϕ(see FIG. 18 for example). The metainformationrepresents a prior on the entropy parameters of the latents, renderingit an entropy model that is normally termed hyperprior.

However, a factorised prior ignores the notion of any dependencystructure. This means that if the true latent distribution does haveintervariable dependencies, a factorised prior would not be able tomodel these; the equal sign in Equation (2.12) would become anapproximation sign. Thus, by Equation (2.4), it would never attainoptimal compression performance (see FIG. 19 for example).

2.4 Innovations

We have been very prolific in pushing the frontiers of entropy modellingby rigorous development of theory and experimental tests. This sectionintroduces a range of innovations in this field. Outlined innovationsare segmented in different categories, which are accordingly presentedin the upcoming subsections. The categories are:

-   -   1. More flexible parametric distributions as factorised entropy        models;    -   2. Multivariate entropy modelling through parametric        multivariate distributions;    -   3. Mixture models;    -   4. Non-parametric (factorised and multivariate) density        functions.

2.4.1 Flexible Parametric Distributions for Factorised Entropy Modelling

Some entropy models in AI-based data compression pipelines includefactorised priors p_(y) _(i) , (y_(i); ϕ_(i)), i.e. each variable in thelatent space is modelled independently from other latent variables. Thefactorised prior is often parametrised by a parametric family ofdistributions, such as Gaussian, Laplacian, Logistic, etc. Many of thesedistribution types have simple parametrisation forms, such as a mean (orlocation) parameter and a variance (or scale) parameter. Thesedistribution types often have specific characteristics which typicallyimpose certain constraints on the entropy model, such as unimodality,symmetry, fixed skewness and kurtosis. This impacts modellingflexibility as it may restrain its capacity to model the true latentdistribution, which hurts compression performance.

Therefore, we incorporate more flexibility in entropy modelling by usingparametric distributions as factorised prior. We achieve this byemploying distributions with many degrees of freedom in theparametrisation, including shape, asymmetry and skewness. Note that theinnovation is formulated irrespective of the method with which theparameters ϕ are produced; these may be learned directly as fixedparameters (fully factorised prior), predicted by a hypernetwork(hyperprior) or by a context model (conditional model).

An example of parametric distribution families for factorised entropymodelling covered by this innovation, with the respectiveparametrisations for each distribution, can be seen in FIG. 20 , inwhich K_(λ) denotes the modified Bessel function of the second kind.Note that if a closed-form expression for the CDF is undefined orintractable, there still exist methods to evaluate probability masses(as seen in Section 2.4.2), which are part of our innovations inflexible entropy modelling of latent distributions.

Example: The exponential power distribution is a parametric family ofcontinuous symmetric distributions. Apart from a location parameter μand scale parameter α, it also includes a shape parameter, β>0. The PDFp_(y) (y), in the 1-D case, can be expressed as

${p_{y}(y)} = {\frac{\beta}{2\alpha{\Gamma\left( \frac{1}{\beta} \right)}}\exp\left( {- \left( \frac{❘{y - \mu}❘}{\alpha} \right)^{\beta}} \right)}$

where Γ(·) denotes the gamma function. The shape parameter can bemodulated so as to attain probability densities from the normal (α=2),Laplace (β=1) and uniform (β=∞) distribution families, and a continuumof densities for any arbitrary ŷ value.

We have put a lot of effort into extending this approach to allow thequantised latent space to be modelled using discrete parametricprobability distributions, as opposed to continuous probabilitydistributions. Amongst others, we have tested and modified the followingdistributions to work in an AI-based data compression pipeline:

TABLE 2.2 List of typical discrete parametric probability distributionsconsidered under the outlined method. Discrete parametric distributionsThe Bernoulli distribution The Rademacher distribution The binomialdistribution The beta-binomial distribution, The degenerate distributionat x0 The discrete uniform distribution The hypergeometric distributionThe Poisson binomial distribution Fisher's noncentral hypergeometricdistribution Wallenius' noncentral hypergeometric distribution Benford'slaw The ideal and robust soliton distributions Conway-Maxwell-Poissondistribution Poisson distribution Skellam distribution The beta negativebinomial distribution The Boltzmann distribution The logarithmic(series) distribution The negative binomial distribution The Pascaldistribution The discrete compound Poisson distribution The parabolicfractal distribution

Hyperpriors and Hyperhyperpriors

The entropy parameters in a compression pipeline define a probabilitydistribution that we can evaluate likelihood on. With the evaluatedlikelihoods, we can arithmetically encode the quantised latentrepresentation ŷ into a bitstream, and assuming that the identicallikelihoods are evaluated on the decoding side, the bitstream can bearithmetically decoded into ŷ exactly (i.e. losslessly) (for example,see FIG. 122 ). A hyperprior is a separate neural network module whosepurpose is to encode metainformation in the form of a quantisedhyperlatent representation z, which is encoded and decoded in a similarfashion to the latents, and outputting entropy parameters for the latentrepresentation ŷ (for example, see FIG. 123 ). We can also apply ahyperprior on top of the hyperprior (which we can call hyperhyperprior),whose purpose is to encode metainformation in the form of a quantisedhyperhyperlatent representation ŵ, which also is encoded and decoded ina similar fashion to ŷ and {circumflex over (z)}, and outputting entropyparameters of {circumflex over (z)} (for example, see FIG. 124 ). Thishierarchical process can be applied recursively, such that anyhyperprior module encodes and decodes metainformation regarding theentropy parameters of the lower-level latent or hyperlatentrepresentation.

2.4.2 Parametric Multivariate Distributions

We have considered that the latent distribution is most likely a jointdistribution with conditionally dependent variables. That is, thevariables of ŷ={ŷ₁, . . . , ŷ_(N)}^(T) have statistical dependenciesbetween each other; they are correlated. As previously visited, with afactorised assumption, the dependency structure is not directlymodelled. Hence, if the true latent distribution m_(ŷ)(ŷ) does containstatistical dependencies, a factorised assumption on the entropy modelp_(ŷ) will never attain optimal compression performance (see FIG. 19 forexample).

By leveraging parametric multivariate distributions, we can capturethese statistical dependencies in our entropy modelling if thecorrelations are modelled adequately. For example, the multivariatenormal distribution (MVND), denoted by

(μ, Σ), can be used as a prior distribution. The MVND is parametrised bya mean vector μΣ

^(N) and covariance matrix Σ∈

^(N×N). A comprehensive list of examples of parametric multivariatedistributions under consideration for the methods outlined below can beseen in Table 2.3.

However, there are three leading problems with directly incorporatingintervariable dependencies in our entropy model:

TABLE 2.3 List of typical parametric multivariate distributionsconsidered under the outlined method. Parametric multivariatedistributions Multivariate normal distribution Multivariate Laplacedistribution Multivariate Cauchy distribution Multivariate logisticdistribution Multivariate Student's t-distribution Multivariatenormal-gamma distribution Multivariate normal-inverse-gamma distributionGeneralised multivariate log-gamma distribution Multivariate symmetricgeneral hyperbolic distribution Correlated marginal distributions withGaussian copulas

-   -   1. Previously, without regard for intervariable dependencies, we        normally require        (N) distribution parameters (for instance, μE        ^(N) and σ∈        ^(N) for a factorised normal distribution). However, we require        (N²) distribution parameters in order to take intervariable        dependencies into account. Since N is already a large number for        most purposes, a squaring of the dimensionality becomes unwieldy        in practical applications.    -   2. The quantity expressing intervariable dependencies, normally        a covariance matrix or correlation matrix, introduces additional        complexities to the system. This is because its formulation        requires strong adherence to certain mathematical principles        that, if violated, will trigger mathematical failure mechanisms        (similar to dividing by zero). In other words, we not only need        a correct parametrisation of the intervariable dependencies but        also a robust one.    -   3. Evaluating the probability mass of a parametric multivariate        distribution is complicated. In many cases, there exists no        closed-form expression of the CDF. Furthermore, most        approximations involve non-differentiable operations such as        sampling, which is not backpropagatable during network training.

We have sought to find a remedy to these challenges, and the nextsubsections will shed light on the methods and technologies that enableor facilitate the employment of parametric multivariate distributions inentropy modelling for AI-based compression. Throughout thesesubsections, examples are provided of how each method is appliedassuming MVND as prior distribution.

Latent Space Partitioning for Tractable Dimensionality

In order to take on the challenge of the exploding dimensionality of thelatent space, we provide a way to partition the latent space intosmaller chunks on which we ascribe intervariable correlations. Ideally,these chunks encompass variables that indeed demonstrate correlativeresponses, such as locally in the spatial and channel axes (whenexpressed in array format). By doing so, we prescribe zero correlationfor variables that are far apart and clearly have no mutual influence.This drastically reduces the number of parameters required to model thedistribution, which is determined by the partition size and thereforethe extent of the locality.

It should be noted that the chunks can be arbitrarily partitioned intodifferent sizes, shapes and extents. For instance, assuming array formatof the latent space, one may divide the variables into contiguousblocks, either 2D (along the height and width axes) or 3D (including thechannel axis). The partitions may even be overlapping; in which case,the correlations ascribed to each pair of variables should ideally beidentical or similar irrespective of the partition of which bothvariables are a member of. However, this is not a necessary constraint.

The effects of the reduced number of parameters required using apartitioning scheme can be understood by an example. Using MVND as anentropy model imposed on latent space ŷ∈

^(N), we can split up the latent space into B contiguous partitions ofsize m=16 or blocks of 4×4 variables (pixels) along the spatial axes (asseen in the first example in FIG. 21 ), such that N=Bm since thepartitions are non-overlapping. Then, for each block partition b∈{1, . .. , B}, we require the MVND parameters μ^([b])∈

^(m) and Σ^([b])∈

^(m×m). Whereas a single MVND entropy model on the entire latent spacerequires

$N + \frac{N\left( {N + 1} \right)}{2}$

parameters (the second term is because the covariance matrix issymmetric a partitioned latent space with B MVND entropy models require

${B\left( {m + \frac{m\left( {m + 1} \right)}{2}} \right)} = {N + \frac{N\left( {m + 1} \right)}{2}}$

parameters in total.

Although in this example we have been focused on partitioning of thelatent space for tractable dimensionality, the same principle could beapplied for any vector space encountered in AI-based data compression.

Parametrisation of Intervariable Dependencies

Depending on the parametric distribution type adopted, the quantityexpressing the intervariable dependencies may have differentconstraints. For instance, the absolute magnitude of the elements in acorrelation matrix can never exceed one, and the diagonal elements areexactly one. Some expressions of intervariable dependencies include, butare not limited to, the covariance matrix Σ, the correlation matrix

and the precision matrix Λ. Note that these quantities are closelylinked, since they describe the same property of the distribution:

-   -   Correlations are simply covariances that have been standardised        by their respective standard deviations:

$\rho_{i,j} = \frac{\sum_{i,j}}{\sigma_{i,i}\sigma_{j,j}}$

-   -   The precision matrix is precisely the inverse of the covariance        matrix: Λ=Σ⁻¹

Apart from this, all three expressions share common mathematicalproperties such as symmetry and positive definiteness. Therefore, itmakes sense to narrow in on a single expression when discussing theparametrisation of intervariable dependencies. In this case, we willfocus on the covariance matrix Σ.

There are multiple ways that we could parametrise Σ whilst satisfyingits intrinsic properties. Here are some examples that we havesuccessfully used to date, which are by no means exhaustive.

-   -   By matrix A∈        ^(N×N) such that Σ=A^(T)A+εI_(N), where s is a positive        stability term to avoid degenerate cases (when E becomes        singular and non-invertible);    -   By matrix A∈        ^(N×N) and perform point-wise multiplication with a lower        triangular matrix of ones, M∈        ^(N×N), to obtain L=A⊙M, and then by Cholesky decomposition        obtain Σ=LL^(T);    -   Same as the previous point, but L is constructed directly        (ideally as a vector whose elements are indexed into a lower        triangular matrix form) instead of the masking strategy;

Algorithm 2.1 Mathematical procedure of computing an orthonormal matrixB through consecutive House-holder reflections. The resulting matrix canbe seen as an eigenvector basis which is advantageous in inferring thecovariance matrix. The input vectors can therefore be seen as part ofthe parametrisation of the covariance matrix, which are learnable by aneural network.  1: Inputs:  Normal vectors of reflection hyperplanes{v_(i)}_(i=1) ^(N−1),  v_(i) ∈ 

^(N+1−i)  2: Outputs:  Orthonormal matrix B ∈ 

^(N×N)  3: Initialise:  B ← I_(N)  4: for i ← 1 to N − 1 do  5:  u ←v_(i)  6:  n ← N + 1 − i

 Equals length of vector u  7:  u₁ ← u₁ − sign(u₁)∥u∥₂  8:  $\left. H\leftarrow{I_{n} - {2\frac{uu^{T}}{{❘{❘u❘}❘}_{2}^{2}}}} \right.$

 Householder matrix  9:  Q ← I_(N) 10:  Q_(≥i,≥i) ← H

 Embedding Householder matrix in bottom-right corner of reflection 11: B ← BQ

 Householder reflection of dimensionality n 12: end for

-   -   By the eigendecomposition of Σ, which is a parametrisation        comprising eigenvalues s∈        ₊ ^(N) and eigenbasis B∈        ^(N×N) of the covariance matrix. The eigenbasis is comprised by        eigenvectors along its columns. Since B is always orthonormal,        we can parametrise this through a process termed consecutive        Householder reflections (outlined in Algorithm 2.1), which takes        in a set of normal vectors of reflection hyperplanes to        construct an arbitrary orthonormal matrix. Then, by embedding        the eigenvalues as a diagonal matrix S∈        ^(N×N), diag(S)=s, the covariance matrix is finally computed via        Σ=BSB⁻¹ (where B⁻¹=BT holds since B is orthogonal). One        advantage with this parametrisation is that the inverse of the        covariance matrix (the precision matrix) is easy to evaluate,        since Σ⁻¹=BS⁻¹B⁻¹.

Example: Suppose our entropy model p_(y) over a (partitioned) latentspace is an N-dimensional MVND, y˜

(μ, Σ). We will assume that Σ is parametrised by its eigendecomposition,the eigenvalues s and eigenbasis B (by Householder). Then, we canperform PCA whitening to decorrelate the zero-centred variables y−μ bytransforming with the inverse of the eigenbasis

z=B ⁻¹(y−μ)=B ^(T)(y−μ)

where z is the decorrelated latent vector. The decorrelated latentvariables are now all mutually independent, and distributed as anuncorrelated MVND with eigenvalues as its variances s

z˜

(0,I s)

whose probability mass can be evaluated as a joint factorised normaldistribution:

${P_{\mathcal{z}} = {\prod\limits_{i = 1}^{N}{P_{{\mathcal{z}}_{i}}\left( {\mathcal{z}}_{i} \right)}}},{{\mathcal{z}}_{i} \sim {\mathcal{N}\left( {0,s_{i}} \right)}}$

Approximate Evaluation of Probability Mass

To engage with multivariate distributions in an entropy coding setting,we must be able to unambiguously evaluate probability masses. Normally,for simple univariate parametric distributions, there often exists aclosed-form expression for the CDF (Equation (2.7)), which provides easyprobability evaluation. This is no longer the case for multivariateparametric distributions.

For any continuous probability distribution with a well-defined PDF, butlacking a well-defined or tractable formulation of its CDF, we can usenumerical integration through Monte Carlo (MC) or Quasi-Monte Carlo(QMC) based methods. These methods estimate the probability mass over ahyperrectangular integration region Ω⊂

^(N) on the N-dimensional PDF p_(y)(y; ϕ). These methods rely on uniformsampling of a large number, say M, of pseudo-random or quasi-randomperturbation vectors within a zero-centred integration domain, expressedover the dimensions in product form as Ω=Π_(i=1) ^(N)[a_(i), b_(i)]=[a₁,b₁]×[a₂, b₂]× . . . ×[a_(N), b_(N)]. Then, given a sufficiently largesampling size, the probability mass associated with an arbitrarycentroid ŷ_(n) over the integration domain Ω can be approximated by

$\begin{matrix}{{P\left( {\overset{\hat{}}{y}}_{n} \right)} = {{{V(\Omega)} \cdot {{\mathbb{E}}_{\epsilon\sim{\mathcal{U}(\Omega)}}\left\lbrack {p_{y}\left( {{\overset{\hat{}}{y}}_{n} + \epsilon} \right)} \right\rbrack}} \approx {\frac{V(\Omega)}{M}{\sum\limits_{j = 1}^{M}{p_{y}\left( {{\overset{\hat{}}{y}}_{n} + \epsilon_{j}} \right)}}}}} & (2.13)\end{matrix}$

where V(Ω)=Π_(i=1) ^(N)(b_(i)−a_(i)) is the integration volume over Ωand the perturbation vector is sampled uniformly within the integrationboundaries ∈_(j)˜

(Ω).

Note that MC- and QMC-based evaluation of probability mass can be doneboth for univariate and multivariate distributions. This method is alsonot directly backpropagatable because of the sampling process, howeverit would be feasible to employ this method in gradient-based training byusing gradient overwriting. Furthermore, to avoid non-deterministicprobability mass evaluations between encoding and decoding, the samepseudo- or quasi-random process must be agreed upon between either sidesof the transmission channel.

In the special case for an MVND, there exists another way of evaluatingan approximate probability mass (apart from the PCA whitening approachas explained in previous section) which actually is differentiable. Themethod will be described in the example below.

Example: A joint distribution p(y) that belongs to the family of MVND,has the property that the conditional distributions of its variables arealso normally distributed. That is, the conditional distribution of avariable, given the previous variables, p(y_(i)|y₁, . . . , y_(i−1)) isa univariate Gaussian with the conditional parameters ϕ_(i)=(μ _(i), σ_(i)). Assuming the usual parametrisation of our MVND, μ and Σ, theconditional parameters can be retrieved as such

${\overset{¯}{\mu}}_{i} = {\mu_{i} + {C_{i}\left( {\begin{bmatrix}y_{1} \\y_{2} \\ \vdots \\y_{i‐1}\end{bmatrix} - \ \begin{bmatrix}\mu_{1} \\\mu_{2} \\ \vdots \\\mu_{i‐1}\end{bmatrix}} \right)}}$${\overset{\_}{\sigma}}_{i}^{2} = {\Sigma_{i} - {C_{i}\begin{bmatrix}\Sigma_{1,i} \\\Sigma_{2,i} \\ \vdots \\\Sigma_{i‐1,i}\end{bmatrix}}}$

where C_(i) is the matrix of regression coefficients

$C_{i} = {\left\lbrack \begin{matrix}\Sigma_{1,i} & \Sigma_{2,i} & \ldots & \Sigma_{{i - 1},i}\end{matrix}\  \right\rbrack\begin{bmatrix}\Sigma_{1,1} & \Sigma_{1,2} & \ldots & \Sigma_{1,i‐1} \\\Sigma_{1,2} & \Sigma_{2,2} & \ldots & \Sigma_{2,i‐1} \\ \vdots & \vdots & \ddots & \vdots \\\Sigma_{1,i‐1} & \Sigma_{2,i‐1} & \ldots & \Sigma_{i‐1,i‐1}\end{bmatrix}}^{- 1}$

and where the inverse operation is the generalised (Moore-Penrose)pseudoinverse.

With the conditional parameters, the probability mass would be estimatedin the same way as a univariate normal distribution. Importantly, thisformulation is only approximate since the conditioning occurs over asingle point, whereas in reality, the probability mass is evaluated overa closed interval on the probability density function. In practicehowever, as long as the distribution is not converging towards adegenerate case, this method provides a useful approximation forprobability mass evaluation whenever Σ is obtained directly and rateevaluation requires differentiability.

FIG. 22 shows an example visualisation of a MC- or QMC-based samplingprocess of a joint density function in two dimensions. The samples areabout a centroid ŷ with integration boundary Ω marked out by therectangular area of width (b₁-a_(i)) and (b₂-a₂). As per Equation(2.13), the probability mass equals the average of all probabilitydensity evaluations within Ω times the rectangular area.

Copulas

We established that multivariate probability density distributions arehard to learn and evaluate with naive methods and require specificapproaches to make them work. One of these is using Copula.

In probability theory and statistics, a copula is a multivariatecumulative distribution function for which the marginal probabilitydistribution of each variable is uniform on the interval [0, 1]. Copulasare used to describe the dependence between random variables. In short,Copula is a way to get value from a joint probability distribution usingmarginal distributions plus a couple-function (→ the Copula). Thiscouple function is there to introduce correlation/dependencies betweenthe marginals.

Let's assume we modelled the latent space with a factorised distribution{P_(y1), . . . , P_(yN)}, but we want to model it using a jointdistribution P_(y)(.). If we assume that our factorised distributionsare the marginal distribution of the joint distribution, we can useCopula. Note that this assumption is not always valid, but there areclasses of distributions for which this holds, e.g. the multivariatenormal distribution, the multivariate Laplace distribution, and others.If we want the joint (multivariate) cumulative distribution functionCumP_(y)(y₁, y₂, . . . , y_(N))=Prob(Y₁≤y₁, . . . , Y_(N)≤Y_(N)), we canexpress CumP_(y)(·) as a Copula function C with inputs being theevaluation of the marginal cumulative distributions:

CumP_(y)(y ₁ ,y ₂ , . . . ,y _(N))=C(CumP_(Y) ₁ (y ₁), . . . ,CumP_(Y)_(N) (Y _(N)))  (2.14)

Moreover, we can get the density function of the joint distribution bysimply differentiating the copula function. Let P_(y) be the jointdensity function and P_(y) _(i) the factorised density functions. Toillustrate:

P _(y)(y ₁ ,y ₂ , . . . ,Y _(N))=c(CumP_(Y) ₁ (y ₁), . . . ,CumP_(Y)_(N) (y _(N)))·P _(Y) ₁ (y ₁) . . . P _(Y) _(N) (Y _(N))  (2.15)

The above equation states that the properties of dependence are oftenefficiently analysed using copulas. An n-dimensional copula is just afancy name for a joint probability distribution on the unit square [0,1]² with uniform marginals. FIG. 23 visualises a bivariate Copula.

So what is the Copula function C(·), and how to create it? The copula Ccontains all information on the dependence structure between thecomponents of (Y₁, Y₂, . . . , Y_(N)). The Copula C(·) is the jointdistribution of the cumulative transformed marginals.

The transformed marginals into [0, 1] (probability space):

(U ₁ , . . . ,UN)=(CumP_(Y) ₁ (y ₁), . . . ,CumP_(Y) _(N) (Y_(N)))  (2.16)

The Copula function:

C(u ₁ , . . . ,U _(N))=Prob(U ₁ ≤u ₁ , . . . ,U _(N) ≤U _(N))  (2.17)

Let's go through an example to build an intuition behind what Copula is.It is often used to generate correlated random variables of “difficult”distributions. Let's assume we want correlated random variables from ajoint (multivariate) hyperbolic distribution. Well, no library canquickly generate these, so what can we do?

If we know the marginal (factorised) distributions of the jointdistribution and the correlation that we want, the task is possible. Wesimulate random correlated variables given the joint multivariatedistribution. We transform them to correlated variables in [0,1] usingthe joint normal distribution's marginals' cumulative distributions. Were-transform these values in a joint hyperbolic distribution by usingthe inverse marginal cumulative distributions of the joint hyperbolic.FIG. 24 illustrates an example of this process.

This process is only possible by using the Copula approach.

Our innovation is to use Copula for latent distribution modelling in twoways:

-   -   1. It gives us an effective way to create an n-dimensional        correlated random variable of an arbitrary distribution (see        FIG. 24 for example). This is tremendously useful to model        “better” noise when using multivariate joint distributions for        latent modelling. When we train our neural network, we have to        use noise to guarantee a Gradient flow. If we are in the        n-dimensional world, our noise must be correlated, and Copula        lets us generate and learn such noise.    -   2. If we want to learn a joint probability distribution, either        discrete or continuous, Copula gives us an effective way of        imposing marginal distribution constraints on the learned joint        distribution. Usually, when learning a joint distribution, we        can not control the marginals. However, we can use the Equation        (2.15) to impose marginal constraints. In this case, we would        learn the Copula (joint uniform distribution), have our        marginals given and combine them to a joint distribution that        respects our marginals.

Characteristic Functions

In our world, for everything, there is a dual-representation or duality.For instance, in Physics, we have the Wave-particle duality; for images,we have their representation in the spatial or the frequency domain, andfor probability distributions, we have their characteristic functions.Usually, in one world, we can evaluate points easily but struggle withtheir impact on the surrounding area (particles, spatial domain,probability functions); whereas in the other, we can evaluate theirwaveform easily but struggle with their impact at a specific point(waves, frequency domain, characteristic functions).

If a random variable admits a density function, then the characteristicfunction is its dual, in the sense that each of them is a Fouriertransform of the other. Let φ_(X)(t) be the characteristic function at(wave) position t for random variable X. If the random variable X hasthe probability density function ƒ_(x)(x) and the cumulativedistribution function F_(x)(x), then the characteristic function isdefined as follows:

φ_(X)(t)=E[e ^(itX) ]=

e ^(itx) dF _(x)(x)=

e ^(itx)ƒ_(x)(x)dx  (2.18)

The following table summarises the above paragraph. Note that pointevaluation in the spatial domain is equivalent to wave evaluation in thewave domain. The wave evaluation in the spatial domain is equal to pointevaluation in the wave domain.

Probability Density Characteristic Functions Functions Point Evaluationsin Spatial Domain: Easy Hard Wave Evaluations in Spatial Domain: HardEasy Point Evaluations in Wave Domain: Hard Easy Wave Evaluations inWave Domain: Easy Hard

Our innovation is to combine our latent density modelling with thecharacteristic function in multiple ways:

-   -   1. Suppose we want to learn a probability density function over        the latent space. In that case, it is often easier to learn its        characteristic function instead and then transform the learned        characteristic function into a density function using the        Fourier Transform. Why is this helpful? The purpose of        characteristic functions is that they can be used to derive the        properties of distributions in probability theory. Thus, it is        straightforward to integrate desired probability function        constraints, e.g. restrictions on the moment-generating        function, φ_(X)(−it)=M_(X)(t), into the learning procedure. In        fact, combining characteristic functions with a learning-based        approach gives us a straightforward way of integrating prior        knowledge into the learned distribution.    -   2. Using probability density functions, we are in the        dual-formulation of the spatial world. Point-evaluations are        easy (e.g. factorised models), group-/wave-evaluations are hard        (e.g. joint probability models). Using characteristic functions        is precisely the opposite. Thus, we can use characteristic        functions as an easy route to evaluate joint probability        distributions over the pixel space x by evaluating factorised        distributions over the wave space t. For this, we transform the        input of the latent space into the characteristic function        space, then evaluate the given/learned characteristic function,        and convert the output back into the joint-spatial probability        space. FIG. 25 visualises an example of this process.

2.4.3 Mixture Models

Most of the parametric distributions that have been explored here thusfar exhibit unimodality, i.e. their PDF formulation has at most a singlepeak or cluster. There is nothing that restricts the true latentdistribution from being multimodal, or having multiple distinct peaks.In fact, this is especially true for multidimensional latent spacessince signals tend to aggregate into clusters if they carry similarinformation, and separate from others if the information is dissimilar.This creates a natural proclivity for multimodality of the latent space.If the latent space truly is multimodal, a unimodal entropy model willnot be able to model it perfectly.

In order to incorporate multimodality to entropy modelling, it ispossible to employ mixture models as prior distribution. A mixture modelis comprised by K number of mixture components, which are basedistributions either from the same family of distributions or different,including non-parametric families of distribution (see Section 2.4.4).The PDF p_(y) is then a weighted sum of each mixture component, indexedby [k]

$\begin{matrix}{{p_{y}(y)} = {{{\pi^{\lbrack 1\rbrack}{p_{y}^{\lbrack 1\rbrack}(y)}} + {\pi^{\lbrack 2\rbrack}{p_{y}^{\lbrack 2\rbrack}(y)}} + \ldots + {\pi^{\lbrack K\rbrack}{p_{y}^{\lbrack K\rbrack}(y)}}} = {\sum\limits_{k = 1}^{K}{\pi^{\lbrack k\rbrack}{p_{y}^{\lbrack k\rbrack}(y)}}}}} & (2.19)\end{matrix}$

where π^([k])∈[0, 1] represents the mixture weight for the PDF of thekth component p_(y) ^([k]). All mixture components must be defined overthe same vector space, and all mixture weights have to sum up to one toensure a proper probability distribution Σ_(k=1) ^(K)π^([k])=1 (whichcan be done with a simple softmax operation). This implies that amixture model actually generalises all distributions (see FIG. 17 forexample), since it can easily model unimodal distributions by settingall π^([k]) but one to zero.

FIG. 26 shows an example of a mixture model comprising 3 MVNDs, eachparametrisable as individual MVNDs, and then summed with weightings.

2.4.4 Non-Parametric Probability Distributions

A main drawback with parametric probability distributions is that they,ironically, impose a prior on the distribution it tries to model. If thedistribution type is not compatible with the optimal latent spaceconfiguration, the prior effectively stifles the learning process.

We have investigated the generation of non-parametric probabilitydistributions for entropy modelling. Non-parametric probability modelsare not defined a priori by a parametric family of distributions, butare instead inferred from the data itself. This gives the network manymore degrees of freedom to learn the specific distribution that it needsto model the data accurately. The more samples per unit interval, themore flexible the distribution. Important examples are histogram modelsand kernel density estimation.

There are multiple ways of modelling the distribution without aparametric form. One simple way is to train a neural network l=ƒ_(ψ)(t),parametrised by network weights, biases and activations p which takesthe range of values with non-zero probability as input t and outputslogits l for discrete probability masses for the range. For example, ifthe quantised latents ŷ∈

consist of rounded integers with minimum and maximum (ŷ_(min), ŷ_(max))respectively, then t={ŷ_(min), y_(min)+1, . . . , ŷ_(max)−1, ŷ_(max)}.The outputted logits would be of the same size as its input ƒ_(ψ):

_(Q) ^(|t|)→

^(|t|), where |t| denotes the number of elements in the vector t. Toensure that we obtain a valid probability distribution, the logits mustsum up to one either by normalisation

${P\left( y_{i} \right)} = {{\frac{{abs}\left( l_{i} \right)}{{\sum}_{j = 1}^{❘t❘}{{abs}\left( l_{j} \right)}}{or}{P\left( y_{i} \right)}} = \frac{l_{i}^{2}}{{\sum}_{j = 1}^{❘t❘}l_{j}^{2}}}$

or using the softmax operation

${P\left( y_{i} \right)} = \frac{\exp\left( l_{i} \right)}{{\sum}_{j = 1}^{❘t❘}{\exp\left( l_{j} \right)}}$

This strategy of learning a discrete PMF can be extended to learning acontinuous PDF by interpolating the values between adjacent discretepoints (P(y_(i)), P(y_(i+1))) that are obtained. Extra care must betaken to ensure that the probability density integrates up to one. Iflinear (spline) interpolation is used, we obtain a piece-wise lineardensity function whose integral can be easily evaluated using thetrapezoidal rule (see FIG. 27 for example). If spline interpolation of ahigher order is used, more powerful numerical integration methods suchas Simpson's rule or other Newton-Cotes formulas (up to a small degreeof error) may be used.

However, this strategy comes with two problems; the range of values tmust be finite and known in advance, and the array indexing operations(which is inherently discrete) that is required to infer probabilitiesdoes not lend itself well to automatic differentiation frameworks.Hence, another method of interest is learning a 1-D (factorisable)cumulative density function (CDF) which can then be used with Equation(2.7) for rate evaluation. This method relies on designing,parametrising and training a neural network that maps a value directlyto a continuous CDF, ƒ_(ψ):

→[0, 1] which satisfies two constraints:

-   -   Cumulative density bounds: ƒ_(ψ)(−∞)=0; ƒ_(ψ)(∞)=1    -   Monotonicity:

$\frac{\partial f_{\psi}}{\partial y_{i}} = {{p_{\psi}\left( y_{i} \right)} \geq 0}$

The first constraint can be satisfied by performing a sigmoid operation

${\sigma(x)} = \frac{1}{1 + {\exp\left( {- x} \right)}}$

on the return value, or any other range-constraining operation (such asclipping, projection, etc). For the second constraint, there are manypossibilities to satisfy this which depends on the network architectureof ƒ_(ψ). For instance, if the network is comprised by a composition ofK vector functions (convolutions, activations, etc)

ƒ_(ψ)=ƒ_(K)∘ƒ_(K−1)∘. . . ∘ƒ₁  (2.20)

its partial derivative with respect to the input, i.e. the PDF p_(ψ), isdefined as a chain of matrix multiplications of the Jacobian matrices(which describes partial derivatives with respect to a vector-valuedfunction) of all function components:

p _(ψ) =J _(ƒK) J _(ƒK−1) . . . J _(ƒ) ₁   (2.21)

Without loss of generality, to satisfy the monotonicity constraint, wemust ensure that the Jacobian matrix of each function component withrespect to the input is non-negative. Examples how this is ensured is byusing monotonic (strictly increasing) activation function such as ReLU,Leaky ReLU (with a positive slope), sigmoid and the hyperbolic tangent,and ensuring that all elements in weight matrices of the linear layersare non-negative. Since the method with which the CDF constraints aresatisfied varies with the network architecture of ƒ_(ψ), the details ofhow this is implemented is not the important aspect, but rather the stepof satisfying these constraint to admit a proper CDF is important.

2.5 Concepts

In this section, we present the following concepts regarding flexibleentropy modelling of latent distributions for AI-based data compressionwith details outlined in the referenced sections. These are consideredunder the context of entropy modelling of the latent distributions aswell as the wider domain of AI-based data compression.

Section 2.4.1, “Flexible Parametric Distributions for Factorised EntropyModelling”

-   -   Application of continuous parametric distributions for entropy        modelling and the wider domain of AI-based compression, and any        associated parametrisation processes therein, including        parametric distribution families that generalises the landscape        of admissible distributions for entropy modelling (such as the        family of exponential power distributions);    -   Application of continuous parametric distributions, and any        associated parametrisation processes therein, for entropy        modelling associated with a “shape”, “asymmetry” and/or        “skewness” parameter;    -   Application of discrete parametric distributions, and any        associated parametrisation processes therein, for entropy        modelling.

Section 2.4.2, “Parametric Multivariate Distributions”

-   -   Application of parametric multivariate distributions,        factorisable as well as non-factorisable, and any associated        parametrisation processes therein, for AI-based data        compression; including, but not limited to, the distribution        types listed in Table 2.3;

Section 2.4.2, “Latent Space Partitioning for Tractable Dimensionality”

-   -   Application of a partitioning scheme on any vector quantity,        including latent vectors and other arbitrary feature vectors,        for the purpose of reducing dimensionality in multivariate        modelling.

Section 2.4.2, “Parametrisation of Intervariable Dependencies”

-   -   Parametrisation and application of consecutive Householder        reflections of orthonormal basis matrices, e.g. Algorithm 2.1;    -   Evaluation of probability mass of multivariate normal        distributions leveraging the PCA whitening transformation of the        variates.

Section 2.4.2, “Approximate Evaluation of Probability Mass”

-   -   Application of deterministic or stochastic MC and QMC-based        methods for evaluation of probability mass of any arbitrary        multivariate probability distribution.    -   Evaluation of probability mass of multivariate normal        distributions by analytically computing conditional parameters        from the distribution parametrisation.

Section 2.4.2, “Copulas”

-   -   We can use Copula to generate an n-dimensional noise vector of        arbitrary distribution with arbitrary correlation. Among others,        we can use this noise vector for better quantisation-residual        modelling training the AI-based Compression Pipeline.    -   If we use a multivariate distribution for latent space modelling        and require constraints on the joint distribution's marginal        distributions, we can use Copula to enforce our restrictions.

Section 2.4.2, “Characteristic Functions”

-   -   Instead of learning the density function of our distribution for        latent space modelling, we can learn its characteristic        function. This is the same as there is a unique link between        both. However, learning the characteristic function gives us a        more straightforward way to integrate distribution constraints        (e.g. on the moments) into the probability function.    -   Learning the characteristic function is more powerful than        learning the probability function, as the former generalises the        latter. Thus, we get more flexible entropy modelling.    -   Learning the characteristic function gives us a more accessible        and more potent way to model multivariate distributions, as        waves (n-dimension input) are modelled as points in the        frequency domain. Thus, a factorised characteristic function        distribution equals a joint spatial probability function.

Section 2.4.3, “Mixture Models”

-   -   Application of mixture models comprised by any arbitrary number        of mixture components described by univariate distributions, and        any associated parametrisation processes therein, for entropy        modelling and the wider domain of AI-based compression.    -   Application of mixture models comprised by any arbitrary number        of mixture components described by multivariate distributions,        and any associated parametrisation processes therein, for        entropy modelling and the wider domain of AI-based compression.

Section 2.4.4, “Non-Parametric Probability Distributions”

-   -   Application of probability distributions parametrised by a        neural network in the form of spline interpolated discrete        probability distribution, and any associated parametrisation and        normalisation processes therein, for entropy modelling and the        wider domain of AI-based compression.    -   Application of probability distributions parametrised by a        neural network in the form of continuous cumulative density        function, and any associated parametrisation processes therein,        for entropy modelling and the wider domain of AI-based        compression.

3. Accelerating AI-Based Image and Video Compression Neural Networks 3.1Introduction

Real-time performance and fast end-to-end training are two majorperformance requirements of an AI-based compression pipeline. To theseends, we have incorporated fast iterative solvers into a compressionpipeline, accelerating both inference, leading to real-time performance,and accelerating the end-to-end training of the compression pipeline. Inparticular, iterative solvers are used to speed up probabilistic models,including autoregressive models, and other probabilistic models used inthe compression pipeline. Additionally, iterative solvers are used toaccelerate the inference speed of neural networks.

AI-based compression algorithms have achieved remarkable results inrecent years, sur-passing traditional compression algorithms both asmeasured in file size and visual quality. However, for AI-basedcompression algorithms to be truly competitive, they must also run inreal-time (typically >30 frames-per-second). To date, the run-time issuehas been almost completely ignored by the academic research community,with no published works detailing a viable real-time AI-basedcompression pipeline.

We have however made significant progress towards achieving a real-timeAI-based compression pipeline. Here we outline one of our methods forattaining real-time AI-based compression, namely: accelerating AI-basedcompression using iterative methods for solving linear and non-linearequations. Iterative methods for equation solving improve severalaspects of the AI-based compression pipeline. In particular they speedup the execution of Neural Networks, and significantly reduce thecomputational burden of using various probabilistic models, includingautoregressive models.

Moreover, aside from improving inference speeds (leading to real-timeperformance), iterative methods can significantly reduce the end-to-endtraining times of an AI-based compression pipeline, which we will alsodiscuss.

3.1.1 Iterative Methods for Equation Solving

First we review iterative methods for solving systems of equations.Suppose we have a set of N variables x₁, x₂, . . . , x_(N). Suppose alsowe have M functions, ƒ₁, . . . , ƒ_(M), each of which takes in the Nvariables and outputs a scalar (a single number). This defines a systemof equations

f₁(x₁, x₂, …, x_(N)) = 0f₂(x₁, x₂, …, x_(N)) = 0⋮f_(M)(x₁, x₂, …, x_(N)) = 0

For brevity we can write this system in vector notation. Define thevector x=(x₁, . . . , x_(N)) and the vector-valued function ƒ=(ƒ₁, . . ., ƒ_(M)). Then the system is simply written

ƒ(x=0  (3.1)

A solution to (3.1) is a particular x that, when evaluated by ƒ, makes(3.1) true. Importantly, not all x are solutions. Finding solutions to(3.1) is in fact difficult, in general. Only in very special cases, whenthe system of equations has special structural properties (such astriangular systems), can a solution to (3.1) be solved exactly, and eventhen, exact solutions may take a very long time to compute.

This is where iterative methods for equation solving arise. An iterativemethod is able to compute (possibly approximate) solutions to (3.1)quickly by performing a sequence of computations. The method begins witha (possibly random) guess as to what the solution of (3.1) is. Then,each computation (iteration) in the sequence of computations updates theapproximate solution, bringing the iterations closer and closer tosatisfying (3.1).

Take for example, the method of fixed-point iteration (sometimes calledJacobi iteration). This method works as follows. An first guess at asolution x⁰ is initialized (e.g. by drawing

Algorithm 3.1 Fixed Point Iteration Given tolerance ϵ; start point x⁰Initialize x ← x⁰ while ||ƒ(x)|| > ϵ do  x ← ƒ(x) end whilevariables randomly, or by setting the initial iterate to zero). Then,for all following iterations t=1, 2, . . . the iterate is set asx^(t+1)=ƒ(x′). Under suitable conditions, the sequence of iterates willconverge to a solution of (3.1). The iterations are terminated when theapproximate solution is close enough to the true solution (usuallymeasured via the residual ∥ƒ(x′)∥). Fixed point iteration is guaranteedto converge if the function ƒ is contractive (its global Lipschitzconstant is less than one).

Fixed point iteration is a very basic method and more sophisticatedapproaches are available. These include

-   -   Gauss-Seidel, in which portions of the current iterate x^(t) are        used to compute the previous iterate x^(t−1)    -   Inexact Newton's methods, in which (3.1) is linearly        approximated at each iterate, and the new iterate is chosen to        reduce the residual of the linear approximation. Some example        Inexact Newton's methods are: Broyden's method, BFGS, L-BFGS    -   Methods which seek to minimize a (scalar) merit function, which        measures how close the iterates are to being a solution (such as        the sum-of-squares Σ_(i=1) ^(M)ƒ_(i)(X)²). These include:    -   Trust-region methods, in which the next iterate is chosen to        decrease a quadratic model of the merit function in a small        neighbourhood about the current iterate.    -   Line-search methods, in which the next iterate is chosen to        decrease the merit function along a search direction. The search        direction is chosen by approximating the merit function using a        quadratic model.    -   methods that approximate the Hessian (matrix of second        derivatives) of the merit function with a low-rank approximation    -   first order methods which only use gradient or sub-gradients. In        this setting, the solution of the system is found by        reformulating the problem as finding the minimum of a scalar        objective function (such as a merit function). Then, a variable        is optimized using a (sub-)gradient-based optimization rule. A        basic form of this is gradient descent. However more powerful        techniques are available, such as proximal-based methods, and        operator splitting methods (when the objective function is the        sum of several terms, some terms may only have sub-gradients but        closed-form proximal operators).

Each of these methods can be shown to converge to a solution, givenparticular constraints on the function ƒ. Often these constraintsinvolve calculating bounds on the minimum and maximum eigenvalues of theJacobian of ƒ. Convexity requirements may be required for convergence toa unique solution, but are not in general needed for convergence to asolution.

3.2 Innovation: Iterative Solvers for Autoregressive Models in aCompression Pipeline

In an AI-based compression pipeline, we seek to compress an image orvideo x=(x₁, x₂, . . . , x_(N)), where x is a vectorized representationof the image or video. Each component x_(i) of the vector is a pixel ofthe image (or frame, if discussing videos). To encode the image or videoas an image, we need a joint probability model p(x) which measures thelikelihood of the image occurring. The filesize of the encoded image isbounded above by the (cross-)entropy of the probability model—the closerthe probability model is to the true distribution of images, the betterthe compression rate (filesize).

However, working with the joint distribution is difficult. Instead, wemay exploit the chain rule of probability: the joint distribution isequal to a product of conditional distributions. That is, we willfactorize the joint distribution as follows:

$\begin{matrix}{{p(x)} = {p\left( {x_{1},x_{2},\ldots,x_{n}} \right)}} \\{= {{p\left( x_{1} \right)}{p\left( {x_{2}❘x_{1}} \right)}{p\left( {{x_{3}❘x_{2}},x_{1}} \right)}\ldots{p\left( {{x_{N}❘x_{N - 1}},x_{N - 2},\ldots,x_{1}} \right)}}} \\{= {\prod\limits_{i = 1}^{N}{p\left( {x_{i}❘x_{{1:i} - 1}} \right)}}}\end{matrix}$

Each of the p(x_(i)|x_(1:i−1)) are conditional probabilities. Theymeasure the probability that pixel x_(i) occurs, given that the value ofthe preceding pixels x_(1:i−1).

This factorized distribution, as a product of conditional distributions,is in general much easier to work with. This is especially true in imageand video compression. When an image is compressed, and sent as abitstream, it is not the value of the pixels x that is sent, but rathera vector of conditional probability values that is actually converted toa bitstream. This conditional probability vector is defined as

$\begin{matrix}{\hat{p} = \begin{bmatrix}{p\left( x_{1} \right)} \\{p\left( {x_{2}❘x_{1}} \right)} \\{p\left( {{x_{3}❘x_{2}},x_{1}} \right)} \\ \vdots \\{p\left( {{x_{N - 1}❘x_{N - 2}},\ldots,x_{1}} \right)} \\{p\left( {{x_{N}❘x_{N - 1}},\ldots,x_{1}} \right)}\end{bmatrix}} & (3.2)\end{matrix}$

To emphasize, the vector P is the quantity that is actually compressed(by sending it to for example an arithmetic encoder). At decode time,when the image is to be recovered, we must recover x from theconditional probability vector. In other words, we must solve for x fromthe system of equations

$\begin{matrix}{{{p\left( x_{1} \right)} = {\hat{p}}_{1}}{{p\left( {x_{2}❘x_{1}} \right)} = {\hat{p}}_{2}}{{p\left( {{x_{3}❘x_{2}},x_{1}} \right)} = {\hat{p}}_{3}} \vdots {{p\left( {{x_{N - 1}❘x_{N - 2}},\ldots,x_{1}} \right)} = {\hat{p}}_{N - 1}}{{p\left( {{x_{N}❘x_{N - 1}},\ldots,x_{1}} \right)} = {\hat{p}}_{N}}} & (3.3)\end{matrix}$

This is an inverse problem, a system of equations that can be solvedusing one of the iterative methods described above. To make the link toEquation (3.1) clear, we could define the vector valued function ƒ asthe vector of conditional probability functions minus {circumflex over(p)}. Then the system of equations is in the form of (3.1):

$\begin{matrix}{{f(x)}:={{\begin{bmatrix}{p\left( x_{1} \right)} \\{p\left( {x_{2}❘x_{1}} \right)} \\{p\left( {{x_{3}❘x_{2}},x_{1}} \right)} \\ \vdots \\{p\left( {{x_{N - 1}❘x_{N - 2}},\ldots,x_{1}} \right)} \\{p\left( {{x_{N}❘x_{N - 1}},\ldots,x_{1}} \right)}\end{bmatrix} - \hat{p}} = 0}} & (3.4)\end{matrix}$

Note that system (3.4) has a triangular structure: the i-th conditionalprobability depends only on the value of the previous variables. Thismakes it particularly easy to solve, especially using the Jacobiiterative method (fixed point iteration). In fact, with anautoregressive model, the Jacobi iterative method is guaranteed toconverge to the true solution in at most N steps. In practice however,an acceptable approximate solution can be achieved in significantlyfewer steps, depending on the tolerance threshold E (refer to Algorithm3.1).

3.2.1 Solver Speed

Triangular systems can also be solved serially, one equation at a time.In a linear system, this is called forward substitution (backwardsubstitution). In a serial solution method, first x₁ is solved from theequation p (x₁)={circumflex over (p)}₁. Then, x₁ is substituted into theequation p(x₂|x₁)={circumflex over (p)}₂, which is then solved for x₂.Both x₁ and x₂ are substituted into the third equation, which is thensolved for x₃. The process is continued serially through all equationsuntil finally the entire vector x is recovered.

Unfortunately, this serial process is very slow. It requires exactly Nsteps, and cannot be done with any fewer calculations. Contrast thiswith an iterative method, which can converge to an acceptable solutionin significantly fewer than N iterations. Moreover, the serialprocedure's computations are applied one element (pixel) at a time. Incontrast, the iterations of the fixed point scheme (or any iterativemethod) are applied to the entire image, and can exploit parallelizationroutines of modern hardware (such as Graphics Processing Unit or aNeural Processing Unit).

3.2.2 Types of Autoregressive Models

What form do the conditional probability functions p(x_(i)|x_(1:i−1))take? We now review types of autoregressive probabilistic models thatmay be used in a compression pipeline. One useful approach is to modelthe probability function is with a basic 1-dimensional probabilityfunction with parameters θ. The parameters θ will be the functions ofthe preceding x_(1:i−1) variables. So for example, we could modelp(x_(i)|x_(1:i−1)) with the Normal distribution

p(x _(i) |x _(1:i−1))=N(x _(i);μ(x _(1:−1)),σ(x _(1:i−1)))  (3.5)

Here the mean parameter μ and the variance parameter σ are the output offunctions of x_(1:i−1). In an AI-based compression pipeline, typicallyneural networks are used for these functions.

There are many possible choices of autoregressive models that can beused to encode the variable into a bitstream. They are all variants ofthe choice of function used to model the conditional probabilities. Thefollowing is a non-exhaustive list. (In the following examples we usethe Normal distribution as the “base” distribution, but any distributioncould be used)

-   -   Intrapredictions and block-level models In Intrapredictions and        its variants, an image is chopped into blocks (rectangles, or        squares, of pixels). The idea is to build an autoregressive        model at the block level. Pixels from preceding blocks are used        to create an autoregressive model for each pixel in the current        block. Typically only adjacent blocks preceding the current        block are used.        -   The autoregressive function could be chosen from a family of            functions, chosen so that the likelihood of the current            block is maximized. When the autoregressive function is a            maximum over a family of functions, the family may be a            countable (discrete, possibly finite) or uncountable set (in            which case the family is parameterized by a continuous            indexing variable). In classical Intrapredictions the family            of functions is discrete and finite. The argmax can be            viewed as a type of side-information that will also need to            be encoded in the bitstream (see last point).    -   Filter-bank models The autoregressive function could be chosen        from a set of “filter-banks”, i.e. where the parameters of the        distribution are chosen from a set of models (which could be        linear). The filter-bank is chosen to maximize the probability.        For example,

$\begin{matrix}{{p\left( {x_{i}❘x_{{1:i} - 1}} \right)} = {\max\limits_{k}{\mathcal{N}\left( {{x_{i};{L^{k}x_{{1:i} - 1}}},{M^{k}x_{{1:i} - 1}}} \right)}}} & (3.6)\end{matrix}$

where each Lk and Mk are filter-bank models (possible linear functions).

-   -   Parameters from Neural Networks The parameters could be        functions of Neural Networks, including convolutional NNs. For        example,

p(x _(i) |x _(1:i−1))=

(x _(i);μ(x _(1:i−1)),σ(x _(1:i−1)))  (3.7)

where μ(·) and σ(·) are Neural Networks (possibly convolutional).

-   -   Parameters derived from side-information The parameters of the        probability model could also depend on stored meta-information        (side-information that is also encoded in the bitstream). For        example, the distribution parameters (such as μ and σ) could be        functions of both the previous variables x_(1: −1), and a        variable z that has been encoded and decoded in the bitstream.

p(x _(i) |x _(1:i−1))=

(x _(i);μ(x _(1:i−1) ,z),σ(x _(1:i−1) ,z))  (3.8)

-   -   -   A simple example of this is the case where μ and σ are a            linear functions of x_(1:i−1), where the linear functions            are themselves outputs of non-linear functions of z (such as            a neural network)

p(x _(i) |x _(1:i−1))=

(x _(i) ;L(z)x _(1:−1) ,M(z)x _(1:−1))  (3.9)

Note that the discussion up until this point has been focused on usingautoregressive models for probabilistic modelling on an input image x.However, there are many other variables that autoregressive models canbe used on:

-   -   Latent variables: modeling latent variables is a very typical        use-case here. The latent variables y are the quantized (integer        rounded) outputs of a Encoder neural network.    -   Temporal modeling In video compression, there are many        correlations between video frames located temporally close.        Autoregressive models can be used to model likelihoods of the        current frame given past (or future) frames.

3.2.3 Autoregressive Normalizing Flows

Although conditional probability distributions are a main component ofthe compression pipeline, Deep Render still has use for jointprobability estimation (estimating the unfactorized joint probabilityp(x)). This can be done using a Normalizing Flow (refer to our PCTpatent “Invertible Neural Networks for Image and Video Compression”, andfor a discussion of use-cases). Recall that a joint probabilitydistribution can be estimated by a change of variables ƒ: x∈

^(N)

z∈

^(N):

$\begin{matrix}{{p(x)} = {{\mathcal{N}\left( {{{f(x)};0},I} \right)}{❘{\det\frac{{df}(x)}{dx}}❘}}} & (3.1)\end{matrix}$

Here

(ƒ(x); 0, I) is the standard multivariate normal distribution, and

$❘{\det\frac{{df}(x)}{dx}}❘$

is the determinant of the Jacobian of the transformation ƒ.

Typically, ƒ is constructed to be easily invertible, and also to have atractable determinant formula. This can be done using an autoregressivemodel. The function ƒ could be made of a series of transformations:ƒ(x)=ƒ_(N)∘ƒ_(N−1)∘ . . . ∘ƒ₂∘ƒ₁(x). Each of the ƒ_(i)'s has anautoregressive structure:

ƒ_(i)(y)=g(y _(1:i−1); θ_(i))  (3.11)

where y is the input to the function at the i-th composition. In otherwords, the function at the i-th place in the chain of compositions onlydepends on the preceding i−1 variables. The function g could be anyfunction parameterized by θ that is invertible (bijective). Sodescribed, this is an Autoregressive Flow.

The process of inverting an autoregressive flow is to solve the system

ƒ(x)=z  (3.12)

for x given z. This can of course be done with an iterative solver, andin particular, since the system is triangular (autoregressive), it canbe solved easily with fixed-point iteration (Jacobi iteration). Notethat in an autoregressive flow, the computing the forward map z=ƒ(x) istypically quick and computationally easy, whereas inverting the system(3.12) is hard and computationally more difficult.

An example where the opposite is true is the inverse autoregressiveflow. In this setup, the inverse function ƒ⁻¹(z)=x is modeled as acomposition of functions. ƒ⁻¹(z)=ƒ₁ ⁻¹∘ƒ₂ ⁻¹∘ . . . ∘ƒ_(N−1) ⁻¹∘ƒ_(N)⁻¹(z). Each of the inverse ƒ_(i) ⁻¹'s has an autoregressive structure:

ƒ_(i) ⁻¹(y)=g(y _(i:i−1); θ_(i))  (3.13)

Again, the function g should be bijective so that it can be inverted. Inthis case the change of variables formula is

$\begin{matrix}{{p\left( {f^{- 1}({\mathcal{z}})} \right)} = {{\mathcal{N}\left( {{{\mathcal{z}};0},I} \right)}{❘{\det\frac{{df}^{- 1}({\mathcal{z}})}{d{\mathcal{z}}}}❘}^{- 1}}} & (3.14)\end{matrix}$

And now generating x from z is easy, whereas finding z from x isdifficult and involves solving the system

ƒ⁻¹(z)=X  (3.15)

This system can be solved using an iterative solver.

Continuous Normalizing Flows

One possible variant of the normalizing flow framework is to define thecomposition of functions as infinitesimal steps of an continuous flow.In this setting the final variable z is the solution to an OrdinaryDifferential Equation i=ƒ(z; θ) with initial condition z(0)=x. Thefunction ƒ may have an autoregressive structure. Continuous normalizingflows are appealing in that they are easily inverted (by simply runningthe ODE backward in time) and have a tractable Jacobian determinantformula.

3.3 Innovation: Iterative Solvers for Non-Autoregressive ProbabilisticModels in a Compression Pipeline

The bulk of this section has focused on autoregressive models, their usein compression pipeline, and how they define systems of equations thatcan be solved using iterative methods. However, many of theautoregressive methods can be generalized to non-autoregressive methods.This section will illustrate some non-autoregressive modeling tasks thatcan be solved using iterative methods.

3.3.1 Conditional Probabilities from an Explicit Joint Distribution

Rather than modeling the joint distribution p(x) as an autoregressivefactorization of (autoregressive) conditional probabilities, we maysimply model the conditional probabilities explicitly from a definedjoint distribution.

For example, suppose we model the joint distribution with a standardmultivariate distribution, such as the Multivariate Normal Distribution.

${p(x)} = {{\mathcal{N}\left( {{x;\mu},\sum} \right)} = {\frac{1}{Z}{\exp\left( {{- \left( {x - \mu} \right)^{T}}{\sum}^{- 1}\left( {x - \mu} \right)} \right)}}}$

Here Σ is the covariance matrix and p is a mean vector. The constant Zis a normalizing constant so that the RHS has unit mass.

The conditional probabilities are defined via the following formula(here x_(i)=(x₁, x₂, . . . , x_(i−1), x_(i+1), . . . , x_(N)) is thevector missing the i-th component)

$\begin{matrix}\begin{matrix}{{p\left( x_{i} \middle| x_{\smallsetminus i} \right)} = \frac{p(x)}{p\left( x_{\smallsetminus i} \right)}} \\{= \frac{p(x)}{\int{{p(x)}dx_{i}}}}\end{matrix} & (3.16)\end{matrix}$

The denominator is obtained by marginalizing out the i-th variable.Notice that the conditional probability model here depends both on pastand future elements (pixels). This is a significantly more powerfulframework than an autoregressive model. Notice also that integrationconstants cancel here. So for example, with a Multivariate NormalDistribution, the conditional probability density is

$\begin{matrix}{{p\left( x_{i} \middle| x_{\smallsetminus i} \right)} = \frac{\exp\left( {{- \left( {x - \mu} \right)^{T}}{\sum}^{- 1}\left( {x - \mu} \right)} \right)}{\int{{\exp\left( {{- \left( {x - \mu} \right)^{T}}{\sum}^{- 1}\left( {x - \mu} \right)} \right)}{dx}_{i}}}} & (3.17)\end{matrix}$

The denominator here has a closed form, analytic expression, and so theconditional probability is simple to evaluate. In a compressionpipeline, under this framework, to encode a variable x we wouldconstruct a vector of conditional probabilities {circumflex over (p)},using the tractable formula for conditional probabilities (either (3.16)in general, or (3.17) if using Multivariate Normal). Then, at decodetime, the vector x is recovered by solving the system

$\begin{matrix}{{\begin{bmatrix}{p\left( x_{1} \middle| x_{\smallsetminus 1} \right)} \\{p\left( x_{2} \middle| x_{\smallsetminus 2} \right)} \\ \vdots \\{p\left( x_{N - 1} \middle| x_{{\backslash N} - 1} \right)} \\{p\left( x_{N} \middle| x_{\backslash N} \right)}\end{bmatrix} - \overset{\hat{}}{p}} = 0} & (3.18)\end{matrix}$

for x using an iterative method.

The parameters of the joint distribution (such as for example theprecision matrix Σ⁻¹ and the mean μ) can be produced by a function ofside (or meta-information) also included in the bitstream. For examplewe could model the joint distribution as

${p(x)} = {\frac{1}{Z}{\exp\left( {{- \left( {x - {\mu(z)}} \right)^{T}}{M(z)}\left( {x - {\mu(z)}} \right)} \right)}}$

where z is the side-information variable, and μ(·) and Σ⁻¹=M(·) are theoutputs of functions (possibly neural networks) of the side-information.

3.3.2 Markov Random Fields

Rather than modeling the joint probability distribution with a“standard” multivariate distribution, we can model the jointdistribution with a Markov Random Field. A Markov Random Field(sometimes called a Gibbs distribution) defines a joint probabilitydistribution over a set of variables embedded in an undirected graph

. This graphical structure encodes conditional dependencies betweenrandom variables. So for instance, in an image, the graph variablescould be all pixels in the image, and the graph vertices could be allpairwise adjacent pixels.

Contrast this with autoregressive models: autoregressive models aredefined on directed acyclic graphs; wherease Markov Random Fields aredefined on undirected (possibly cyclic) graphs. Essentially, a MarkovRandom Field is a rigorous mathematical tool for defining a jointprobability model that uses both past and future information (which isnot possible with an autoregressive model).

The unnormalized probability density (sometimes called a score) of aMarkov Random Field can be defined as

$\begin{matrix}{{\overset{\sim}{p}(x)} = {\prod\limits_{c \in {c1{(\mathcal{G})}}}{\phi_{c}\left( x_{c} \right)}}} & (3.19)\end{matrix}$

Here cl(

) are the cliques of the graph. In a graph defined on an image, withedges between pairwise pixels, the cliques are simply the set of allpairwise adjacent pixels. The definition of a clique is well know in thefield of graph theory, and is defined a subset of vertices of a graphsuch that all variables (vertices) of the clique are adjacent to eachother. The functions ϕ_(c) are called clique potentials. Often they aredefined via an exponential ϕ_(c)(x_(c))=exp(ƒ_(c)(x_(c))). In ourcompression pipeline, the functions {ƒ_(c)} could be for examplequadratic functions, neural networks, or a sum of absolute values. Thefunctions ƒ_(c) could be parameterized by a set of parameters θ (whichmay be learned), or the parameters could be the function of some sideinformation.

The joint probability density function is defined by normalizing (3.19)so that it has unit probability mass. This is typically quite difficult,but since in compression we are mainly dealing with conditionalprobabilities, it turns out this normalization constant is not needed.

To illustrate how conditional probabilities are calculated, let'sconsider a simple graph of four random variables (A, B, C, D), withedges {(A, B), (B, C), (C, D), (D, A)}. Note that in this example thecliques are just the edges. The score function is {tilde over (p)}(a, b,c, d)=ϕ₁(a, b)ϕ₂(b, c)ϕ₃(c, d)ϕ₄(d, a). The conditional probability, sayp(a|b, c, d) is given by

$\begin{matrix}{{p\left( {\left. a \middle| b \right.,c,d} \right)} = {\frac{p\left( {a,b,c,d} \right)}{\int{{p\left( {A,b,c,d} \right)}dA}} = \frac{{\phi_{1}\left( {a,b} \right)}{\phi_{4}\left( {d,a} \right)}}{\int{{\phi_{1}\left( {A,b} \right)}{\phi_{4}\left( {A,a} \right)}dA}}}} & (3.2)\end{matrix}$

since cliques without vertex A cancel, and the integration constantcancels as well. Thus conditional probabilities can be easily calculatedwith an analytic expression, provided the integral in the denominator istractable.

Therefore, just like with an autoregressive model, Markov Random Fieldscan be used to encode a variable x via a conditional probabilityvectors. And, just like with an autoregressive model, the variable x maybe reconstructed at decode time by solving a system of equations for xin terms of {circumflex over (p)}. Just like an autoregressive model,the variable to be encoded need not be an image, but could be a latentvariable, or could model temporal frames in a video (or latent variablesof a video).

We remark that other probabilistic quantities can be easily derived fromMarkov Random Fields using iterative methods. For example, the marginalprobabilities can be obtained using belief propagation, and othermessage passing algorithms, which are specific iterative methodsdesigned for Markov Random Fields.

3.3.3 Generic Conditional Probability Models, or Dependency Networks

The conditional probabilities need not be modeled explicitly from aknown joint distribution. Instead, we may simply model each of theconditional probabilities via a function ƒ_(i):

^(N)

[0, 1]. The vector valued function is defined as ƒ=(ƒ₁, . . . , ƒ_(N)).Each of the functions ƒ_(i) could be parameterized via a parameter θ,such as in a neural network. Then on encode the conditional probabilityvector is calculated as {circumflex over (p)}=ƒ(x; θ). The function ƒmay depend on side information z also encoded in the bitstream. Then, ondecode, the variable x is recovered by solving the system {circumflexover (p)}=ƒ(x; θ) for x. This approach is sometimes called a DependencyNetwork.

This process could be inverted, so that a system is solved iterativelyat encode time. Then at decode time, the variable {circumflex over (x)}may be recovered quickly without using an iterative solver. In thissetup, we define a bijective function g: [0, 1]^(N)

^(N). At encode time, the conditional probabilities are given by solvingthe system g({circumflex over (p)})=x for {circumflex over (p)} using aniterative solver, given an image x. (Essentially inverting {circumflexover (p)}=g⁻¹(x). Then, at decode time, the variable is reconstructed bysimply calling the function x=g({circumflex over (p)}).

3.4 Innovation: Iterative Solvers for Evaluating Neural Networks

Finally, we note that iterative solvers need not be used only forprobabilistic modelling. In fact, iterative solvers can be used todecrease execution time of neural networks themselves. The executionpath of a feed-forward neural network itself has a triangular(autoregressive structure). For example, let x₀ be the input to thefirst layer of a neural network. Let ƒ₁, . . . , ƒ_(L) be the layers ofa neural network. Then the output y of a feed forward neural network isgiven by the following non-linear autoregressive (triangular) system

f₁(x₀) = x₁ f₂(x₀, x₁) = x₂ ⋮ f_(L)(x₀, …, x_(L − 1)) = y

Notice that this system is triangular (autoregressive): each linedepends only on the preceding variables. Therefore, a solution can begiven by using an iterative method tailored to autoregressivestructures, such as fixed-point (Jacobi) iteration. In practice, we havefound that this approach can lead to significant speed ups in inferenceand training times.

Differentiation and training may be accomplished using any of themethods discussed in the next section.

3.5 Training Models that are Solved Using Iterative Methods

Using iterative methods inside an end-to-end compression pipeline hasnumerous advantages.

Among the foremost advantages is a reduction in training times. Forexample:

-   -   In autoregressive models, solutions can be obtained either using        an iterative method (the approach of this patent), or serially        (described in Section 3.2). Because iterative methods are in        general much faster than serial methods (cf Sec 3.2), this gives        a corresponding speed-up to end-to-end training times. This        speed-up can be massive, on the order of over several        magnitudes.    -   In non-autoregressive models, solutions cannot be found without        using an iterative solver. Thus, it is simply not possible to        use a non-autoregressive model in an end-to-end training        framework, unless iterative solvers are used. Many powerful        modeling techniques (such as all of those outlined in Section        3.3) are completely out of reach unless iterative methods are        used.

However using iterative methods inside a neural network presents somechallenges, especially in regards to end-to-end training of acompression pipeline. We have taken a number of steps to alleviate theseproblems. The main challenges (and their solutions) of end-to-endtraining with iterative solvers are the following.

3.5.1 Gradient Calculation

In end-to-end training of a compression pipeline with an iterativesolver, we must compute gradients of the solutions outputted by theiterative solver. There are several ways to do this:

-   -   Use an automatic differentiation package to backpropagate loss        gradients through the calculations performed by the iterative        solver. This is typically very slow, and memory intensive, but        it is the most accessible approach. It can be implemented for        example using PyTorch or Tensorflow.    -   Solve another system (iteratively) for the gradient. For        example, suppose        is a scalar loss that depends on the solution x*to the system of        equations ƒ(x*; θ)=0. And suppose we want to differentiate        with respect to a generic variable θ, i.e. compute

$\frac{d\ell}{d\theta}.$

Then, from basic rules of calculus, we first use implicitdifferentiation on the system:

$\frac{df}{d\theta} = {{{\frac{\partial f}{\partial x}\frac{\partial x}{\partial\theta}} + \frac{\partial f}{\partial\theta}} = 0}$

The unknown variable in this system is

$\frac{\partial x}{\partial\theta}.$

It can be solved for using an iterative solver (while the expression

$\frac{\partial f}{\partial x}\frac{\partial x}{\partial\theta}$

is a Jacobian-vector product and can be easily evaluated with automaticdifferentiation). Once a solution is found, then it is dropped in, viathe chain rule, to calculate

$\frac{d\ell}{d\theta} = {\frac{\partial\ell}{\partial x}\frac{\partial x}{\partial\theta}}$

-   -   The gradient can be approximated and learned using an        proxy-function (such as a neural network). In probabilistic        modeling this is called score-matching, whereby the gradients of        the log-likelihood are learned by minimizing the difference        between the grad log-likelihood and the proxy-function.

3.5.2 Access to Ground Truth Quantized Variables

Often in an AI-based compression pipeline, the variable to be solved forin a system of equations is a quantization of another variable. However,during training, it is not feasible to access (calculate) the quantizedvariable—it would simply take too long, making training unfeasible.Typically the quantized variable in question is a quantized latentŷ=Q(y). This is the problem of accessing the ground-truth quantizedlatent during training. Several approaches have been developed toovercome this problem during our training, including:

-   -   Approximating the ground truth quantized latent (variable) by        adding noise to the unquantized latent (variable), e.g. ŷ=y+η,        where η is sampled as a random variable from some distribution,        such as uniform noise.    -   Predict ŷ using an auxiliary function, ŷ=ƒ_(θ)(y), where ƒ_(θ)        is function parameterized by θ (such as a neural network). The        auxiliary function can be trained in a bi-level fashion, i.e. it        can be trained concurrently with the main compression pipeline.        The auxiliary function can be trained to minimize a loss such as        MSE or any other distance metric; or it can be trained using a        Generative Adversarial Network (GAN) based approach.

All iterative solvers in this document can be adapted to solve forquantized variables, if during training the solvers given access to asimulated (approximate) quantized variable. Of course, ideally theground-truth quantized latent would be used, but in general this isdifficult, and remains an active area of research.

3.6 Concepts

-   -   1. Using iterative methods for speedup during inference in the        AI-based Compression pipeline for non-autoregressive components.    -   2. Using iterative methods for speedup during inference for        auto-regressive approaches in the AI-based Compression pipeline.    -   3. Using iterative methods for speedup during inference for        auto-regressive approaches in general.    -   4. Using iterative methods for speedup during training the        AI-based Compression pipeline for non-autoregressive components.    -   5. Using iterative methods for speedup during training for        auto-regressive approaches in the AI-based Compression pipeline.    -   6. Using iterative methods for speedup during training for        auto-regressive approaches in general.    -   7. Using custom gradient-overwrite methods to get the gradients        of black-box iterative solvers for speedup during training for        auto-regressive approaches (see section 3.1)    -   8. Using custom gradient-overwrite methods to get the gradients        of black-box iterative solvers for speedup during training for        auto-regressive approaches (see section 3.1)    -   9. Modelling the (required) ground truth quantized latent for        autoregressive approaches in the AI-based Compression pipeline        via generative or discriminative methods (see section 3.2)

4. Learning a Perceptual Metric 4.1 Introduction

In AI-based compression, the rate and distortion are the two mainobjectives we aim to optimise. The rate aims to make the message we arestreaming as small as possible in size (bits), while the distortion aimsto keep the fidelity of the received message as close to that of thesent message. Translating this to the transmission of an image, thesender encoding the image using the codec, hoping to reduce it's filesize as much as possible, streams it to the receiver, who decodes theimage and hopes that the quality of the image is as good as theoriginal. However, these two aims of reducing the file size andmaintaining the quality are at odds with each other. Reducing the filesize of an image makes the quality of the image worse (lossycompression).

There are multiple ways to define a distortion/fidelity metric inAI-based training, and the only requirement they have is that they besmooth and differentiable in order for us to be able to differentiatethem with respect to their inputs. This makes training our AI-basedcompression pipeline feasible. Along with this, another aspect that hasrecently been considered important for a distortion metric is that itmust be tuned to the human visual system. In other words,differentiability is not the only criteria for our distortion metric,but it must now take into account the human visual system. Asking amathematical function to take into account the human visual system isimpossible currently, as it firstly assumes we understand how humansperceive images (what they prefer in an image and what they discard),and secondly that we can build such a complex function in adifferentiable way.

The method aims to solve this problem by learning a function that takesas input a distorted and ground truth (GT) image, and outputs a scorewhich indicated how a human viewer would perceive the image (1 is poorquality, 10 is indistinguishable from GT). A requirement is that we havesome human labelled data to teach our function. Furthermore, we outlinesome training strategies and methods to enhance our results.

Ultimately, the function learnt, called Deep Visual Loss (DVL) acts asthe distortion metric and is used to train a compression pipeline forimage and video compression.

4.2 Data Acquisition

We learn to approximate the human visual system in a supervised fashion,where we define a function ƒ and subsequently teach it to fit the humanlabelled data. For this learning process, we must first acquire thedata. In this section, we outline some methods to acquire the data.

The primary method for acquiring data is through human labelling. Here,we collect a wide variety of images across different quality levels andpresent them to humans and ask them to assess the quality using one ofthe following methods (these methods are well understood and commonlyused in literature of human quality assessment):

-   -   Single stimulus    -   Double stimulus    -   Force alternative choice    -   Similarity judgments

In these test, we ask candidates to select the preferred image or ratean image on a scale of 0 to 5, which gives us a label per image. We dothis over thousands of candidates and images (to get statisticalsignificance) and use statistical methods such as Z-score and extremevalue analysis to reject outliers. The result of this is a collection ofhuman labelled images.

A key component of the data acquisition process is collecting thedistorted image samples humans will assess the quality of. These sampleshave to be representative of what will be seen when the compressionpipeline is being trained. To understand this intuitively, think of thefunction as a mapping from an image to a value. If the input image haspreviously been seen during the training of this function, we are ableto perform the mapping from image to value accurately. However, if theimage it too dissimilar from what was used to train our function, themapping can suffer from inaccuracies, ultimately leading to difficultiesin the training of our compression pipeline.

To mitigate this, we ensure our dataset used to train our functionincludes a wide range of distortions and mainly, distortions introducedusing AI-based compression encoder-decoder pipelines. This is donethrough simply forward passing a set of images through a trainedAI-based compression pipeline. Alternative, it is also possible to savesimages at different time steps of an AI-based compression pipelinetraining, as this will provide better coverage of images we are likelyto see. When saving images during the training of a pipeline, we proposeto use all existing distortion functions.

From herein, this data consisting of images of different qualities andtheir respective human labels will be referred to as acquired data orhuman labelled data (HLD).

FIG. 28 and FIG. 29 show examples of what the acquired data looks likethrough stimulus tests, and alternative forced choice (AFC). It is notclear how to learn a function from AFC results. We provide two methodsto achieve this. Firstly, we convert rankings into scores to be used fortraining our function ƒ. Multiple methods can be employed to achievethis, and we use the Bradley-Terry or Thurstone-Mosteller method toachieve this. Secondly, we provide an architecture where we can learnfrom AFC results. This is explained further in section 4.3.1.

4.3 Function Fitting

In this section, we will detail the methods used to learn ƒ from HLD.Since we have image data and a value to map to, there are many methodsthat can be used here. We outline the details of neural networks andregression based methods.

4.3.1 Deep Neural Network

We propose to use neural networks to learn from the HLD. We refer tothis network as a Deep Visual Loss (DVL) network. Neural networks aretermed as universal function approximators, which essentially means thatgiven a neural network with enough parameters, we can model anarbitrarily complex function.

This makes them attractive as function approximators. There are manyconfigurations we can use when it comes to defining this neural network,and our claim does not limit us to any particular configuration.However, FIG. 30 shows an example of an instantiation of what such amethod could look like.

In FIG. 30 , the x and x_(hat) are passed through separate branches of adeep neural network (blue and green), whose output features are thencombined and passed into the same network (turquoise). The output ofthis network is the visual quality score for the image x_(hat). It isnot necessary for x and x_(hat) to be passed in through separate networkbranches, they can be concatenated and passed in through the samebranch.

Once we have defined such a network, we train it using the HLD in asupervised training scheme using standard and widely known deep learningmethods such as (but not limited to) stochastic gradient decent and backpropagation.

Training of Deep Visual Loss Network

As mentioned above, we train our Deep Neural network on HLD to predictthe labels of HLD, which gives us an indication of how a human wouldrate them image. In this section, we outline some methods to improve ourtraining. The pseudo-code shown in Algorithm 4.1 below shows how thetraining scheme may look like.

Algorithm 4.1 Training algorithm for learning a Deep Visual Loss (DVL)from HLD.   Inputs: Ground truth image: x Distorted image: {circumflexover (x)} Human label for {circumflex over (x)}: h Step: s ← DVL_(θ)(x,{circumflex over (x)}) L ← Loss_Function(s, h)$\left. \frac{dL}{d\theta}\leftarrow{{backpropagate}(L)} \right.$$\left. \theta\leftarrow{{{optimizer} \cdot {step}}\left( {\theta,\frac{dL}{d\theta}} \right)} \right.$Repeat Step until convergence.

Pre-Training

The data acquisition stage is expensive, especially if we want to get asufficient amount of data and capture a wide range of distortions. It isalso the case that the more data deep neural networks have for training,the better they perform. We provide an automated method to generatelabelled data, which is used to pre-train our DVL network before it istrained on HLD. It is widely acknowledged that pre-training can helpwith learning and generalisation. In order to generate this data forpretraining, we use bit allocation (rate) as a proxy for perceptualquality. During this method, we generate the labels for our distorteddata using the bit-rate. Our AI based compression pipeline can beconditioned on or trained for several lambda values. These valuesdetermine the trade-off between the rate (bits allocated to the image)and distortion (visual quality). We use a range of lambda, from low tohigh, to generate distorted images. For our case, higher lambda valuesgenerate visually pleasing images while lower lambda values generatevisually distorted images. We can pair these lambda values with anappropriate visual quality value, giving the lowest lambda 1 and thehighest lambda value of 9, and the ground truth value of 10. Here, 10represents the best visual image and 1 represents the worst image.

This method provides us with a plethora of labelled data, without theneed for human evaluators. This labelled data can be used to train andpre-train our DVL network.

Multiresolution

We propose to make DVL multi-resolution. FIG. 32 shows what a possiblemultiresolution architecture can look like, however, our proposed methodis not limited to just this instantiation. In general, the aim is toinitialise multiple DVL networks, each of which receives a subsampledversion of the input images. This means we are judging the image acrossmultiple resolutions, and the final score is an average of allresolutions leading to a more robust score. The result is averagedduring the training and prediction of these networks. This means that sin Algorithm 4.1 would be computed as:

${s = {\frac{1}{N}{\sum}_{i = 1}^{N}DV{L_{\theta_{i}}\left( {x_{i},{\overset{\hat{}}{x}}_{i}} \right)}}},$

where N is the number of resolutions. FIG. 31 shows a related example.

Ensemble Training

We enhance the training of DVL through initialising and trainingmultiple networks on the data separately. This method is generallyreferred to as an ensemble of networks in literature, and it makes thepredictions more robust, since each of the DVL is randomly initialised,and will find a different minimum on the loss surface. Therefore,averaging the results of these various instantiations, has the affect ofincreasing robustness through decreasing variance and ignoring outliers.

Apart from random initialization of the same network, we use multiplemodels with varying architectures in our ensemble. This is known asmodel variation ensembles.

During the training of an ensemble of these network, we compute the lossof each network separately using its output score s and the respectiveGT value h. However, during inference, we use the average result.

Network Training

Depending on the data acquisition method, we acquire different formatsof training data labels. For examples, when considering single anddouble stimulus tests, we will receive a score for each image, between0-5 (where 0 represents bad quality, and 5 represents good quality).When considering alternative forced choice, we will get a binary output,showing which image is superior.

Training of DVL network can be performed on any one of the dataacquisition methods. To learn on 2FAC data, we are able to convert the2FAC rankings into per image score (using methods existing in literaturesuch as Thurstone-Mosteller or bradley terry), which the DVL network canregress. Alternatively, we can also employ a method by which we feed inall three images of the 2FAC into a network, asking the network topredict distances for each, which we send into a fully connected networkto predict the result of the 2FAC. FIG. 33 shows a possibleconfiguration for this method.

Here the blue and green convolution blocks share weights, and once thenetwork is trained, we can use the score s to train our compressionpipeline.

4.3.2 Regression

Besides using neural networks directly on the images to predict visualloss scores, we are also able to use a weighted mixture of multipleexisting loss functions to predict the visual loss score. When employingthese methods, we refer to the visual loss score as DMOS.

Specifically speaking, we provide an aggregate visual loss functionwhich is based on a set of individual distortion loss metrics, each ofwhich is evaluated for the distorted image with reference to theoriginal image and multiplied with a coefficient before being summedtogether. The coefficients are found by regression analysis between theindividual distortion losses and subjective opinion scores, ensuringthat the final visual loss score correlates highly with HLD. Thefollowing sections will act as a high-level description of theregression based visual loss function.

Given a GT image x, its distorted counterpart z, an enumerated set of Ndifferent distortion loss functions {L_(i)}_(i=1) ^(N)(outlined in alater section) and a set of regressed (polynomial) loss coefficients{{p_(ij)}_(j=0) ^(m)}_(i=1) ^(N) and an intercept value C, the DMOS losscan be expressed as a sum of polynomials

$\begin{matrix}{{{DMOS}\left( {x,\overset{\hat{}}{x}} \right)} = {C + {\sum\limits_{i = 1}^{N}{\sum\limits_{j = 0}^{m}{p_{ij}{L_{i}\left( {x,\overset{\hat{}}{x}} \right)}^{j}}}}}} & (4.1)\end{matrix}$

The individual loss functions {L_(i)} utilised in the DMOS include, butare not limited to, the following:

-   -   PSNR    -   MS-SSIM    -   SSIM    -   Gradient Magnitude Similarity (GMS)        -   Using various filters for gradient estimation such as            Scharr, Sobel, Prewitt, Laplacian and Roberts of various            sizes, but specifically 3×3, 5×5 and 7×7;        -   Using different pooling techniques such as average pooling            (GMSM) and standard deviation (GMSD);        -   Evaluating, weighing and summing GMS components at multiple            different spatial scales (resolutions).    -   PSNR-HVS losses        -   Include PSNR-HVS, PSNR-HVS-M, PSNR-HVS-A and PSNR-HVS-MA, in            the same methodology and weightings as in the original            papers, but not limited to any modifications in these            parameters.    -   Perceptual losses, including the feature loss as described in        existing literature between all intermediate layers of, but not        limited to, any layers of a pre-trained classification networks:        -   VGG-16 and VGG-19        -   ResNet-34, ResNet-50, ResNet-101 and ResNet-152        -   AlexNet        -   MobileNet v2        -   InceptionNet        -   SENet        -   Encoder or Decoder layers of a compression network train on            rate on the rate distortion loss objective. Essentially we            are using the layers of a trained compression network rather            then one trained on classification.    -   Adversarial losses, such as LSGan losses, discriminator losses,        generator losses etc.    -   Variations on the structural similarity index, including:        -   Gradient-based structural similarity (G-SSIM)        -   Feature Similarity Index (FSIM)        -   Information Content Weighted Multiscale SSIM (IW-SSIM)    -   Visual Information Fidelity    -   Geometric Structural Distortion (GSD)    -   Information Fidelity Criterion (IFC)    -   Most Apparent Distortion (MAD)

The aforementioned losses are so-called full-reference image qualityassessment algorithms, which means the distorted image is compared toits reference counterpart. However, DMOS is also intended to incorporateno-reference image quality assessment algorithms, including, but notlimited to:

-   -   RankIQA    -   Natural Image Quality Evaluator (NIQE)    -   Visual Parameter Measurement Index (VPMI)    -   Entropy-based No-reference Image Quality Assessment (ENIQA)    -   Blind/Referenceless Image Spatial Quality Evaluator (BRISQUE)

The coefficients {C_(i)}_(i=0) ^(N) are optimised for using varioustypes of regression analysis against HLD. The goodness-of-fit isassessed by computing various correlation coefficients, such as Pearson,Spearman and Kendall rank correlations, as well as root mean squarederror (RMSE). The types of regressions may be used singularly or incombination with each other and include:

-   -   Linear (ordinary least-squares) regression;    -   Robust regression, utilising these weight functions:    -   Andrews;    -   Bisquare;    -   Cauchy;    -   Fair;    -   Huber;    -   Logistic;    -   Talwar;    -   Welsch;    -   Nonlinear regression, including, but not limited to:    -   Exponential regression;    -   Logistic regression;    -   Asymptotic regression;    -   Segmented regression;    -   Polynomial and rational function regression;    -   Stepwise regression;    -   Lasso, Ridge and ElasticNet regression.    -   Bayesian linear regression    -   Gaussian process regression

One of the provided methods above is to apply Bayesian methods (Bayesianlinear regression & Gaussian process regression) in a similar fashion asdescribed above. The key here is that we get an uncertainty measure witheach prediction. This uncertainty measure indicated how certain themodel is about a particular prediction. This allows us to modify how weupdate our compression network. For example, If we are really certainthat our prediction of the visual loss score is correct, we use thegradients to update our compression network, however, if we are notsure, we can skip that gradient step since it is likely to be incorrectinformation. This is particularly useful when there is not a lot of dataavailable as it is more likely that the model will encounter samples itis uncertain about.

4.3.3 Training of the Compression Pipeline

Finally, once we have a function ƒ trained, our objective is now totrain our compression pipeline through using this ƒ. Below we outlinehow we do this and some additional training strategies.

Building Composite Losses

When training our compression pipeline using ƒ, we add additional termsto the distortion loss such as but not limited to MSE. These additionalterms, which are computed as using the GT and predicted images, are usedalong with the visual loss score obtained from one of the methods aboveto train our compression pipeline. This has the benefit of acting as aregulariser to the visual loss learnt from HLD. For example, in the casewhere visual loss is uncertain, this regulariser loss steps in toprovide gradients for the compression network that are still meaningful.We propose to use any combination and number of losses here, forexamples, one possible combination is to DMOS using deep pre-trainedfeatures whose weights are learnt using linear regression along withPSNR. Another alternative is the use of DVL network with MSE or PSNR.

Adding this additional loss term also helps with stability in trainingof the compression pipeline using ƒ.

Pre-Training

Rather then training using the learnt ƒ from scratch, we train ournetwork using MSE or another distortion function initially for somenumber of iterations, and introduce ƒ in slowly when the network hasstabilised. This method help stabilise training.

Skipping Gradients

It is possible for us to skip the gradients of images we are uncertainabout, or give them a low weighting. This can be done through using theuncertainty measure output by Bayesian methods, where is the uncertaintyvalue σ² is high, we can skip the gradients from the distortion, orspecifically, ƒ.

4.3.4 Use Cases

We use this method in AI based image and video compression as well asniche markets such an AR/VR, self driving cars, satellite and medicalimage and video compression.

4.3.5 Concepts Main Concepts

We learn a function from compression specific human labelled data to beused as part of the distortion function for training AI basedcompression pipeline.

Sub Concepts

-   -   We learn a neural network on human labelled data    -   We use rate as a proxy to generate and automatically label data        in order to pre-train our neural network    -   We use Ensemble methods to improve the robustness of our neural        network    -   We use multi-resolution methods to improve the performance of        our neural network    -   We learn from FAC as well as stimulus test date    -   We learn the mixtures weights of existing losses such as deep        features to predict humans scores.    -   We apply Bayesian methods to this learning process    -   We use the learnt ƒ to train our compression pipeline    -   We use a combination of ƒ learnt on human data and MSE/PSNR to        train our compression pipeline

5. Mind the Gaps: Closing the Three Gaps of Quantisation 5.1Introduction

Quantisation plays an integral role in compression tasks and enablesefficient coding of the latent space. However, it also inducesirreversible information losses, and encumbers gradient-based networkoptimisation due to its uninformative gradients. The causes for thecoding inadequacies due to quantisation and the methods with which wecan alleviate these, including innovations and technologies, aredescribed.

Formally, for input data of any type (image, video, audio, text, etc.),data compression is the task of jointly minimising the descriptionlength of a compact representation of that data and the distortion of arecovered version of that data. In effect, we have two terms, the rate Rand the distortion D, that we simultaneously are finding a minimum foras means of a weighted loss sum

and a trade-off parameter A that describes the relative weighting ofeach term:

=R+λD  (5.1)

Whether it is the traditional or modern kind, the idea of lossycompression is nevertheless incredibly likely to host some form ofdiscretisation procedure. This is called quantisation, which entails themapping of a value from a large set, say, the number 3.1415926536 (ifthe set is all multiples of 0.0000000001), and assigning it to one ofmany pre-determined states, say the number 3.14, from a countablysmaller set (multiples of 0.01). Naturally, there are many, many morestates of the former set than the latter (more exactly, 100 milliontimes more).

Quantisation has strong implications on the compression objective as awhole, especially in the latent space where it is applied. With fewerstates to consider, the ability to describe a state from the quantisedset is more convenient from an information theoretical perspective. Thisfacilitates the task of reducing the description length of thecompressed bitstream, or simply put the rate term. On the other hand,assuming that the original state contains very particular informationabout the source data, quantisation irrevocably discards some of thatinformation as a consequence. If this information cannot be retrievedfrom elsewhere, we cannot reconstruct the source data without inducingdistortions in our approximation.

FIG. 34 shows a plot of the rounding function to nearest integer (withthe “round-to-even” convention) Q(y_(i)) └y_(i)┐. Note how the gradientof the function is zero almost everywhere, with exceptions ofhalf-integers where the gradient is infinity.

Perhaps the most typical form of quantisation in this context isrounding. In compression, it manifests in the rounding of latentvariables in the bottleneck, for instance to the nearest (even) integerpoint, such that the latent space is discretised into finite stateswhich lend itself well to entropy coding. Since entropy coding is anintegral component of the compression pipeline, we cannot get awaywithout incorporating quantisation under this framework.

The problem, in particular for AI-based compression, is thatgradient-based network training requires differentiability through allthe relevant operations. Unfortunately, this gives rise toincompatibilities with quantisation operations, since most do not haveuseful gradients that are necessary for backpropagation. For example, asseen in FIG. 34 , the rounding function has a zero gradient almosteverywhere, except for the half-integer points (the quantisationboundaries) where the gradient is infinity. We therefore requirealternative methods that can relay gradient signals through thequantisation operation, without sacrificing the intended effect ofquantisation. These alternative methods form the bulk of the providedmethods outlined here.

The focus here is to

-   -   (a) introduce, explain and justify the theoretical aspects and        practical details of quantisation in AI-based data compression        in its present form;    -   (b) present a holistic theoretical framework of quantisation,        the so-called 3 gaps of quantisation, around which our        innovations are based;    -   (c) describe and exemplify a number of novel methods and        technologies that deals with the closing of these gaps of        quantisation in the context of AI-based data compression.        The discussions herein mainly focus on quantisation in the        latent (and hyperlatent) spaces for the purpose of the rate        component. However, it should be noted that quantisation also        can be applied to feature and parameter spaces, the latter of        which forms the framework of low-bit neural networks. We provide        a particular set of tools used for quantisation, irrespective of        where it is applied.

5.2 Preliminaries

See section 2.2 for a detailed section on mathematical preliminaries.

5.3 the Role of Quantisation

In this section, we justify the vital role of quantisation in lossyimage compression from the viewpoint of the latent space. Wecharacterise the different types of quantisation, and talk about howquantisation impacts a gradient-based network training process. Wepresent some quantisation strategies known to existing literature, anddraw parallels with the variational inference framework of posteriordistribution matching. Lastly, we introduce the three gaps ofquantisation and their implications in neural networks for AI-based datacompression.

FIG. 35 is an example of a flow diagram of a typical autoencoder underits training regime. The diagram outlines the pathway for forwardpropagation with data to evaluate the loss, as well as the backward flowof gradients emanating from each loss component. It summarises many keypoints explicitly discussed next, and is a useful reference for thefollowing subsections.

5.3.1 Quantising the Latent Space

The latent vector y∈

^(M), or just latents, acts as the transform coefficient which carriesthe source signal of the input data x. It is often, but not necessarily,retrieved from an analysis transform of the data, y=ƒ_(enc)(x); hence,the information in the data transmission emanates from the latent space.

The latents generally consists of continuous floating point values.However, the transmission of floating point values directly is costly,since the idea of entropy coding does not lend itself well to continuousdata. Hence, it is possible to discretise the latent space in a processcalled quantisation Q:

^(M)→

_(Q) ^(M)(where

_(Q) ^(M) denotes the quantised M-dimensional vector space,

_(Q) ^(M)⊂

^(M)). During quantisation, latents are clustered into predefined binsaccording to their value, and mapped to a fixed centroid of that bin(such as rounding to nearest integer). We normally denote quantisedquantities with a hat symbol, such as ŷ.

From a probability perspective, the consequence of a discretisationprocess is that a continuous density collapses to a discrete probabilitymass model. For instance, if the latent variable y_(i) is distributedaccording to a continuous probability model p_(y) _(i) , a quantisationprocess such as integer rounding will aggregate the probability densityinto masses at each integer location P_(ŷ) _(i) . FIG. 36 shows anexample of how quantisation discretises a continuous probability densityp_(y) _(i) into discrete probability masses P_(ŷ) _(i) . Eachprobability mass is equal to the area below p_(y) _(i) for thequantisation interval, Δ_(i) (here equal to 1.0).

The effect of quantisation on the assigned quantisation task is dual. Onone hand, the set of possible values for the latents is reducedsignificantly, allowing for compatibility with entropy modelling whichenables shorter descriptors of the latents. On the other hand, theprocess induces irrecoverable information loss, which significantlylimits expressiveness of the latent variables. This manifests incorruptions and artefacts in the reconstructed image obtained from thedecoder {circumflex over (x)}=ƒ_(dec)(ŷ). Very broadly speaking, thecoarseness of quantisation (for instance, the width of the bins) has thecapacity to determine the rate-distortion tradeoff levels. The coarserthe quantisation, the lower the bitrates achievable but the larger thedistortion. The effects are reversed for finer quantisation.

5.3.2 Scalar Versus Vector Quantisation

In this section, we clarify the distinction between scalar and vectorquantisation given an M-dimensional vector with continuous elementsy=[y₁ y₂ . . . y_(M)]^(T). Scalar quantisation trivially means that eachelement is quantised individually as if they were scalars, withoutregard for other elements in y. Each element can have C_(i) arbitrarycentroids, but the centroids pertain to their own dimension only,ŷ_(i)∈{ŷ_(i) ^([c])}_(c=1) ^(C) _(i)⊂

, ∀i∈[1 . . . M]. Thus, quantisation entails a mapping to the nearestcentroid in each dimension.

Vector quantisation, on the other hand, is a mapping to centroids withexplicit multiple dimensionality. It considers partitions (or theentirety) of the vector, {y^([b])}_(b=1) ^(B) where B is the number ofvector partitions. Each partitioned vector is quantised to a set ofC_(b) centroids, ŷ^([b])∈{ŷ^([b],[c])}_(c=1) ^(C) _(b)⊂

^(|y) ^([b]) ^(|), ∀∈[1 . . . B]. These centroids can be fixed, learnedor inferred.

Moving forwards, when discussing the methods and technologies here, thescalar quantisation framework will be assumed. Nevertheless, all of thepresented methods and technologies work equally well with a vectorquantisation assumption, and all the concepts pertaining to these shouldalso encompass their extension to vector quantisation.

5.3.3 Effects on Gradient-Based Optimisation

Conventionally, the optimisation or training of a neural network g(·) isdone according to the principle of the chain rule. It assumes acomposition of differentiable functions ƒ_(k) during forward propagationof the data to evaluate the output, conventionally a loss metric

g=ƒ _(K)∘ƒ_(K−1)∘. . . ∘ƒ₁  (5.2)

where each function outputs a hidden state h_(k) which acts as the inputfor the next function:

h _(k)=ƒ_(k)(h _(k−1))  (5.3)

Gradient-based optimisation of neural networks relies on computing thefirst-order gradients of some loss function

=g(x). These gradients then flow backwards through the differentiableoperations in a process called backpropagation by virtue of the chainrule (making the independent variable a scalar for visibility)

$\begin{matrix}{\frac{\partial\mathcal{L}}{\partial h_{k - 1}} = {\frac{\partial\mathcal{L}}{\partial h_{k}}\frac{\partial h_{k}}{\partial h_{k - 1}}}} & (5.4)\end{matrix}$

where

$\frac{\partial h_{k}}{\partial h_{k - 1}}$

is simply the derivative of ƒ_(k) with respect to the input. Thegradient signal cascades backwards and updates the learnable networkparameters as it goes. For this to work effectively, the derivative ofeach function component in the neural network must be well-defined.Unfortunately, most practical quantisation functions have extremelyill-defined derivatives (see FIG. 34 as such an example), which meansthat all gradient signals would be cancelled beyond this point inbackpropagation. This suggests that gradient-based optimisation and truequantisation are mutually incompatible; hence, we need to work aroundeither of them.

We start by exploring whether we would be able to replace gradient-basedoptimisation. Given a set of M continuous latent variables, assume thatthe optimal quantised latent configuration is retrieved by eitherrounding up or down to the nearest integer. This task can be formulatedas an integer or discrete optimisation problem, which is clearlyintractable (a so-called NP-hard problem): the possible evaluationpoints would be of order 2^(M), where M is already a large number (inthe order of 10⁴ to 10⁵). Consequently, it seems most likely that wehave to find workarounds for the non-differentiability property ofquantisation functions.

5.3.4 Quantisation Proxies

Can we make quantisation differentiable? It certainly seems so; let ustake the example of the integer rounding function as quantisationfunction, and rewrite it like this:

Q(y _(i))=└y _(i) ┐=y _(i)+(└y _(i) ┐−y _(i))=y _(i)+ε(y _(i))  (5.5)

Here, we have defined the function ε:

→[−0.5, +0.5] as the quantisation residual, the difference between thequantised and unquantised variable (for integer rounding). Under thesecircumstances, the quantisation residual is limited in magnitude, andcan be seen as an additive term to the original input. Hence, we canmodel the effects of quantisation with a quantisation proxy

{tilde over (Q)}(y _(i))=y _(i)+ε_(i)  (5.6)

where ε_(i) is no longer input-dependent but is rather a noise vectorsampled from an arbitrary distribution, such as a uniform one, ε_(i)˜

(−0.5, +0.5). Since we do not need gradients for the sampled noise, wecan see that this quantisation proxy has a well-defined gradient:

$\begin{matrix}{\frac{\partial\overset{\sim}{Q}}{\partial y_{i}} = 1} & (5.7)\end{matrix}$

From here on in, it becomes convenient to distinguish between truequantisation operations and quantisation proxies. The former refers tooperations that actually discretises the space, making it convenient forentropy coding and other desirable properties during inference anddeployment. The latter refers to differentiable stand-in functions thatmimic the behaviour of the discretisation process, whilst retaining acontinuous space to allow for network training or applications wheregradient propagation is required.

Indeed, automatic differentiation packages allow for customisation ofbackward functions. In other words, we could define a functionalexpression for

$\frac{\partial\overset{\sim}{Q}}{\partial y_{i}}$

that would allow gradients to pass through in any desired manner. Thisis called gradient overriding which also has the ability to form validquantisation proxies.

FIG. 37 outlines a number of possible quantisation proxies that can beused in network training.

5.3.5 Relation to Variational Inference

Data compression is related to a variational inference framework,through its aim of minimising the Kullback-Leibler (KL) divergencebetween the true posterior distribution p_(θ)(ŷ|x) and an approximatevariational distribution q_(ϕ)(ŷ|x) (obtained from the encoder afterquantisation). The optimisation problem is traditionally posed as such

$\begin{matrix}{\min\limits_{\phi,\theta}{{\mathbb{E}}_{x\sim p_{x}}\left\lbrack {D_{KL}\left( {{q_{\phi}\left( {\overset{\sim}{y}❘x} \right)} \parallel {p_{\theta}\left( {\overset{\sim}{y}❘x} \right)}} \right)} \right\rbrack}} & (5.8)\end{matrix}$

where the expectation is taken over the empirical data distributionp_(x)(x) and ϕ and θ are the parameters for the inference and generativemodels, respectively. The objective function in Equation (5.8) can beexpanded to form a sum of loss terms:

$\begin{matrix}\begin{matrix}{{{\mathbb{E}}_{x\sim p_{x}}\left\lbrack {D_{KL}\left( {{q_{\phi}\left( {\overset{\sim}{y}❘x} \right)} \parallel {p_{\theta}\left( {\overset{\sim}{y}❘x} \right)}} \right)} \right\rbrack} = {{{\mathbb{E}}_{x\sim p_{x}}\left\lbrack {{q_{\phi}\left( {\overset{\sim}{y}❘x} \right)}\log\frac{q_{\phi}\left( {\overset{\sim}{y}❘x} \right)}{p_{\theta}\left( {\overset{\sim}{y}❘x} \right)}} \right\rbrack} =}} \\{= {{\mathbb{E}}_{x\sim p_{x}}{{\mathbb{E}}_{\overset{\sim}{y}\sim q_{\phi}}\left\lbrack {{\log{q_{\phi}\left( {\overset{\sim}{y}❘x} \right)}} -} \right.}}} \\{\left. {}{\log{p_{\theta}\left( {\overset{\sim}{y}❘x} \right)}} \right\rbrack =} \\{= {{\mathbb{E}}_{x\sim p_{x}}{{\mathbb{E}}_{\overset{\sim}{y}\sim q_{\phi}}\left\lbrack {{\log{q_{\phi}\left( {\overset{\sim}{y}❘x} \right)}} -} \right.}}} \\{\left. {}{\log\frac{{p_{\theta}\left( {x❘\overset{\sim}{y}} \right)}{p_{\theta}\left( \overset{\sim}{y} \right)}}{p_{\theta}(x)}} \right\rbrack =} \\{= {{\mathbb{E}}_{x\sim p_{x}}{{\mathbb{E}}_{\overset{\sim}{y}\sim q_{\phi}}\left\lbrack {{\log{q_{\phi}\left( {\overset{\sim}{y}❘x} \right)}} -} \right.}}} \\\left. {}{{\log{p_{\theta}\left( {x❘\overset{\sim}{y}} \right)}} - {\log{p_{\theta}\left( \overset{\sim}{y} \right)}} + {\log{p_{\theta}(x)}}} \right\rbrack\end{matrix} & (5.9)\end{matrix}$

It can indeed be shown that each of these terms relate to specific lossterms occurring in data compression. For instance, the likelihood term(the second one) log p_(θ)(x|{tilde over (y)}) is related to thedistortion or reconstruction loss, and the differential entropy term(the third one) represents the encoding costs of {tilde over (y)}. Thelast term log p_(θ)(x) is simply the marginal distribution of theobserved data, which we cannot influence; hence, we can drop this termfrom the scope of optimisation.

The focus for quantisation falls on the first term, log p_(θ)({tildeover (y)}|x), which is the logarithm of the conditional distribution ofthe approximate latents given the data input. Since an encoder normallymaps our input to raw latents, y=ƒ_(enc)(x), the conditionaldistribution becomes dependent on the quantisation that is imposed onthe latents. In many instances, independent uniform noise quantisationis assumed as the quantisation proxy which yields the following propertyfor q_(ϕ)({tilde over (y)}|x):

$\begin{matrix}{{q_{\phi}\left( \overset{\sim}{y} \middle| x \right)} = {\prod\limits_{i}{\mathcal{U}\left( {\left. {\overset{\sim}{y}}_{i} \middle| {y_{i} - \frac{1}{2}} \right.,\ {y_{i} + \frac{1}{2}}} \right)}}} & (5.1)\end{matrix}$

It can be argued that since a uniform distribution with unit width hasconstant probability density of 1, the logarithm of this densityevaluates to zero. However, this is not a trivial assumption; withoutthis assumption for your quantisation proxy, this term cannot beignored. Our studies indicate that the noise distribution is neitherfactorised nor symmetric, and may indeed be highly context-dependent. Wemean that the distribution of quantisation residuals contain certainstatistical dependencies, which suggests that if we are able to modelthem during training, the optimisation process would imitate thecompression task with true quantisation more closely.

5.3.6 the Three Gaps of Quantisation

In the field of AI-based data compression where gradient-basedoptimisation and quantisation both play integral roles, but are mutuallyincompatible, the discretisation process introduces certain inadequaciesthat manifest as differences between the ideal case and practical case.

We can identify and characterise three such gaps:

-   -   1. The discretisation gap: Represents the misalignment in the        forward-functional behaviour of the quantisation operation we        ideally want to use versus the one used in practice.    -   2. The entropy gap: Represents the mismatch of the cross-entropy        estimation on a discrete probability distribution versus a        continuously relaxed version of it.    -   3. The gradient gap: Represents the mismatch in the        backward-functional behaviour of the quantisation operation with        respect to its forward-functional behaviour.

TABLE 5.1 Typical quantisation proxies and whether they suffer from anyof the three gaps of quantisation. Discretisation Entropy GradientQuantisation proxy gap gap gap (Uniform) noise quantisation ✓ ✓

Straight-through estimator (STE)

✓ STE with mean subtraction

✓ Universal quantisation ✓ ✓ ✓ Stochastic rounding ✓

✓ Soft rounding ✓ ✓

Soft scalar/vector quantisation ✓ ✓

The Discretisation Gap

Under many deep learning applications, it is ideal to work withcontinuous (real) values. Since a discretisation process such asrounding breaks the continuity, it does not lend itself well togradient-based network optimisation. One way we could remedy this is bysubstituting the true quantisation operation Q(·) with a quantisationproxy {tilde over (Q)}(·) during network training. In inference anddeployment, we do not require differentiability, during which we wouldrevert back to using Q(·). Thus, the discretisation gap refers to themisalignment in the outputs ŷ_(i) and {tilde over (y)}_(i), produced byQ(·) and {tilde over (Q)}(·), respectively. An example of a quantisationproxy that yields a discretisation gap is noise quantisation, {tildeover (Q)}(y_(i))=y_(i)+ε_(i)={tilde over (y)}_(i) where ε_(i) are randomsamples drawn from an arbitrary noise source (the selection of the noisesource is a design choice). While it is intended to simulate the effectsof true quantisation such as rounding, Q(y_(i))=└y_(i)┐=ŷ_(i), it isclear that in general {tilde over (y)}_(i)≠ŷ_(i).

Since the loss function consists of two components, the rate R anddistortion D, both of which is dependent on the quantised latentvariable, the misalignment in the quantisation output propagates onwardto each of the loss component. Crucially, the quantised latentsconditioning each component do not need to be the same. Past thequantisation function, the algorithm branches out where, on one hand,the entropy model computes the rate term from the first version of thequantised latents ŷ^([R]), and on the other hand, the decoder (orhyperdecoder) admits the second version of the quantised latentsŷ^([D]). This implies that we, in fact, have two discretisation gaps toconsider for each set of latents (see FIG. 35 for example).

The Entropy Gap

Most entropy coding schemes are only defined for discrete variables, andtherefore require a discrete probability model (or entropy model). Theproblem is that discrete probability models do not provide usefulgradients for continuous inputs. Usually, a continuous relaxation of theentropy model is adopted, for instance by employing uniform noisequantisation as quantisation proxy. If the true quantisation is integerrounding, uniform noise quantisation with noise sampled from

(−0.5, 0.5) has the property that the resulting continuous densitycoincides with the discrete probability distribution. FIG. 38 shows anexample in which uniform noise quantisation {tilde over(Q)}(y_(i))=y_(i)+ε_(i), ε_(i)˜

(−0.5, +0.5) gives rise to a continuous relaxation of the PMF P_(ŷ) _(i). The resulting distribution is equivalent of the base distributionconvolved with a unit uniform distribution, p_(ŷ) _(i) =p_(y) _(i) *

(−0.5, +0.5), and coincides with all values of the PMF.

However, the differences in the character of the probabilitydistributions give rise to misalignment in the likelihood evaluationbetween the continuous and discrete models. This inadequacy is termedthe entropy gap.

Although the entropy gap might seem related to the discretisation gap,there are a couple of fundamental differences. Most importantly, thediscrepancy manifests itself in the evaluated likelihood for the rateterm, where the continuous approximation will in most casesunderestimate this quantity. Secondly, whilst the discretisation gappertains to both the rate term and distortion term, the entropy gap onlyconcerns effects on the rate.

The Gradient Gap

The gradient gap arises when the gradient function of the assumedquantisation proxy has been overridden with a custom backward function.For instance, since the rounding function has zero-gradients almosteverywhere, the STE quantisation proxy {tilde over (Q)}(·) assumes itsderivative to be equal to be one, such that

$\frac{\partial\overset{\sim}{Q}}{\partial \cdot} = 1$

(see FIG. 39 for example). Under these circumstances, the encoder willreceive gradient signals from the loss function as if it had producedquantised variables directly.

For every quantisation proxy that is defined with its own custombackward function that is misaligned with the forward function'sanalytical derivative, the gradient gap is manifested.

5.4 Innovations

We have been very prolific in pushing the frontiers of quantisation forAI-based data compression by our rigorous development of theory andexperimental tests. This section introduces a range of innovations.These are all presented thematically in their own individual subsectionsbelow.

5.4.1 Eliminating Gradient Bias with Laplacian Entropy Model

Choosing the family of parametric distributions for the entropy modelmay at first glance appear to be detached from quantisation. However, asshall be seen momentarily, the choice of the parametrisation for theentropy model assumed for the latent distribution p_(y) matters a greatdeal for quantisation, especially with regards to eliminating gradientbiases that arise from the quantised variable.

Consider the rate loss function of the continuously relaxed likelihoodp(y_(i); ϕ_(i)) which is a cross-entropy term

=−log₂ p({tilde over (y)} _(i);ϕ_(i))  (5.11)

where the likelihood is often evaluated as a difference in CDFs of halfa quantisation bin's distance from the evaluation point,

$\frac{\Delta_{i}}{2}$

$\begin{matrix}{{p\left( {{\overset{\sim}{y}}_{i};\phi_{i}} \right)} = {{F_{\phi_{i}}\left( {{\overset{\sim}{y}}_{i} + \frac{\Delta_{i}}{2}} \right)} - {F_{\phi_{i}}\left( {{\overset{\sim}{y}}_{i} - \frac{\Delta_{i}}{2}} \right)}}} & (5.12)\end{matrix}$

Differentiating

R with respect to {tilde over (y)}_(i) (and assigningp_({tilde over (y)}) _(i) =p({tilde over (y)}_(i); ϕ_(i)) forshort-hand), we obtain:

$\begin{matrix}{\frac{\partial\mathcal{L}_{R}}{\partial{\overset{\sim}{y}}_{i}} = {{{- \frac{1}{{\ln(2)}p_{{\overset{\sim}{y}}_{i}}}}\frac{\partial p_{{\overset{\sim}{y}}_{i}}}{\partial{\overset{\sim}{y}}_{i}}} = {{- \frac{1}{{\ln(2)}p_{{\overset{\sim}{y}}_{i}}}}\left( {\frac{\partial F_{\phi_{i}}}{\partial{\overset{\sim}{y}}_{i}}❘_{{\overset{\sim}{y}}_{i} - \frac{\Delta_{i}}{2}}{- \frac{\partial F_{\phi_{i}}}{\partial{\overset{\sim}{y}}_{i}}}❘_{{\overset{\sim}{y}}_{i} - \frac{\Delta_{i}}{2}}} \right)}}} & (5.13)\end{matrix}$

Using the fact that the gradient of the CDF is equal to the PDF,

${\frac{\partial F_{\phi_{i}}}{\partial{\overset{\sim}{y}}_{i}} = p_{\phi_{i}}},$

we obtain

$\begin{matrix}{\frac{\partial\mathcal{L}_{R}}{\partial{\overset{\sim}{y}}_{i}} = {{{- \frac{1}{{\ln(2)}p_{{\overset{\sim}{y}}_{i}}}}\frac{\partial p_{{\overset{\sim}{y}}_{i}}}{\partial{\overset{\sim}{y}}_{i}}} = {{- \frac{1}{{\ln(2)}p_{{\overset{\sim}{y}}_{i}}}}\left( {{p_{\phi_{i}}\left( {{\overset{\sim}{y}}_{i} + \frac{\Delta_{i}}{2}} \right)} - {p_{\phi_{i}}\left( {{\overset{\sim}{y}}_{i} - \frac{\Delta_{i}}{2}} \right)}} \right)}}} & (5.14)\end{matrix}$

For a univariate Laplacian distribution, the PDF p({tilde over (y)}_(i);μ_(i), b_(i)) and CDF F({tilde over (y)}_(i); μ_(i), b_(i)) have theanalytical formulae

$\begin{matrix}{{p\left( {{{\overset{\sim}{y}}_{i};\mu_{i}},b_{i}} \right)} = {\frac{1}{2b_{i}}{\exp\left( {- \frac{❘{{\overset{\sim}{y}}_{i} - \mu_{i}}❘}{b_{i}}} \right)}}} & (5.15)\end{matrix}$ $\begin{matrix}{{F\left( {{{\overset{\sim}{y}}_{i};\mu_{i}},b_{i}} \right)} = {\frac{1}{2} + {\frac{1}{2}{{sign}\left( {{\overset{\sim}{y}}_{i} - \mu_{i}} \right)}\left( {1 - {\exp\left( {- \frac{❘{{\overset{\sim}{y}}_{i} - \mu_{i}}❘}{b_{i}}} \right)}} \right)}}} & (5.16)\end{matrix}$

Assuming integer quantisation (Δ_(i)=1.0) and plugging in theseequations into Equation (5.14), we get

$\begin{matrix}{\frac{\partial\mathcal{L}_{R}}{\partial{\overset{\sim}{y}}_{0,i}} = {- \frac{{\left( {b_{i}{\ln(2)}} \right)^{- 1}{\exp\left( {- \frac{❘{{\overset{\sim}{y}}_{0,i} + {1/2}}❘}{b_{i}}} \right)}} - {\exp\left( {- \frac{❘{{\overset{\sim}{y}}_{0,i} - {1/2}}❘}{b_{i}}} \right)}}{\begin{matrix}\left( {{{{sign}\left( {{\overset{\sim}{y}}_{0,i} + \frac{1}{2}} \right)}\left( {1 - {\exp\left( {- \frac{❘{{\overset{\sim}{y}}_{0,i} + {1/2}}❘}{b_{i}}} \right)}} \right)} -} \right. \\\left. {{{sign}\left( {{\overset{\sim}{y}}_{0,i} - \frac{1}{2}} \right)}\left( {1 - {\exp\left( {- \frac{❘{{\overset{\sim}{y}}_{0,i} - {1/2}}❘}{b_{i}}} \right)}} \right)} \right)\end{matrix}}}} & (5.17)\end{matrix}$

where {tilde over (y)}_(0,i)={tilde over (y)}_(i)−μ_(i). Interestingly,if

${{❘{\overset{\sim}{y}}_{0,i}❘} > \frac{1}{2}},$

then sign

$\left( {{\overset{\sim}{y}}_{0,i} + \frac{1}{2}} \right) = {{sign}\left( {{\overset{\sim}{y}}_{0,i} - \frac{1}{2}} \right)}$

which is +1 if the variable is positive and −1 if it is negative. Takingthis into account, we can rewrite Equation (5.17) by breaking up thedomain of {tilde over (y)}_(0,i):

$\begin{matrix}{\frac{\partial\mathcal{L}_{R}}{\partial{\overset{\sim}{y}}_{0,i}} = \left\{ \begin{matrix}{{- \left( {b_{i}{\ln(2)}} \right)^{- 1}},} & {{{if}{\overset{\sim}{y}}_{0,i}} < {- \frac{1}{2}}} \\{\left( {b_{i}{\ln(2)}} \right)^{- 1},} & {{{if}{\overset{\sim}{y}}_{0,i}} > \frac{1}{2}} \\{\frac{\sinh\left( {{\overset{\sim}{y}}_{0,i}/b_{i}} \right)}{b_{i}{\ln(2)}\left( {{\exp\left( {1/\left( {2b_{i}} \right)} \right)} - {\cosh\left( {{\overset{\sim}{y}}_{0,i}/b_{i}} \right)}} \right)},} & {otherwise}\end{matrix} \right.} & (5.18)\end{matrix}$

We should now be able to see that if the input variable is larger than ½in magnitude, the gradient of the rate loss is constant. This impliesthat any gradient biases are guaranteed to vanish for noise quantisationproxies when |y_(0,i)|>Δ since the additive noise has a maximummagnitude of ½. This entails the nice equality that

$\frac{\partial\mathcal{L}_{R}}{\partial_{{\overset{\hat{}}{y}}_{0,i}}} = {\frac{\partial\mathcal{L}_{R}}{\partial_{{\overset{\sim}{y}}_{0,i}}} = {\frac{\partial\mathcal{L}_{R}}{\partial_{y_{0,i}}}.}}$

For STE quantisation proxy, the same holds true but for

${❘y_{0,i}❘} > {\frac{\Delta}{2}.}$

As justification, FIG. 40 plots the gradient

_(R) of a Laplacian entropy model and compares it against one of aGaussian model, where the gradients are biased to the quantisation. Itshows rate loss curves (solid curves) and their gradients (dashedcurves). Left: Laplacian entropy model. Since the gradient magnitude isconstant beyond

$\frac{\Delta}{2},$

the gradient signal would always be equivalent for a rounded latentvariable ŷ_(i)=└y_(i)┐=y_(i)+ε(y_(i)) as for a noise-added latent if|y_(i)|>Δ. Right: Gaussian entropy model. The same does not apply for aGaussian entropy model, where it is clear that

$\frac{\partial\mathcal{L}_{R}}{\partial_{{\overset{\hat{}}{y}}_{i}}} \neq {\frac{\partial\mathcal{L}_{R}}{\partial_{y_{i}}}.}$

5.4.2 Twin Tower Regularisation Loss

One of the unwanted effects of closing the entropy gap, such as with STEquantisation proxies, is that the discretisation of the entropy modelinhibits continuity in the gradient flow. Since the probability space isdiscrete, our gradient signals will also be discrete and dependent onthe values of the quantised variables. Unfortunately, this hasdetrimental effects on the optimisation task.

Consider the dashed plots in FIG. 40 . Imagine that the domain isdiscretised to all integers; the continuous curve plots would bereplaced by discontinuous dots/squares for each integer position. Thisis shown in FIG. 41 for example, which shows the discontinuous lossmagnitudes and gradient responses if the variables are truly quantisedto each integer position (left: Laplacian entropy model; right: Gaussianentropy model). This has the following three meanings:

-   -   The gradient signals will be identical for all values that        quantise to the same bin, regardless how similar or different        they are;    -   The latents are maximally optimised for rate if the latent        variables quantise to zero;    -   Once the latents are quantised to zero, it will receive zero        gradient signal from the rate loss.

However, the inherent rate-distortion tradeoff prevents a total collapseof the latent space to zero from happening. The distortion requiresinformation in the latent space to be maintained, and so it encouragesthe latent variables to spread away from zero. The combined effects ofSTE quantisation ignoring smoothness of values within a quantisation binand the counteracting gradient signals of the rate and distortion lossesyields a phenomenon which has been dubbed the twin tower effect. Theresults of this is that latent values cluster heavily around the firstquantisation boundaries on each side of zero, most often −0.5 and +0.5for integer quantisation. See FIG. 42 for example, which shows anexample of a histogram visualisation of the twin tower effect of latentsy, whose values cluster around −0.5 and +0.5.

One immediate remedy for this phenomenon would be to penalise latentdensity from accumulating at quantisation boundaries. This has theeffect of introducing auxiliary gradients which are missing from therate loss when ŷ_(i) is zero, and thus assists in moderating thegradient gap. This could be done with a penalty function added to theloss function weighted with a coefficient that yields the maximum valuewhen |y_(i)|=0.5.

Example: We could append our loss formulation from Equation (5.1) with apenalty loss term, λh(y, σ) where λ is a weighting coefficient and

${h\left( {y,\sigma} \right)} = {{\exp\left( {- \frac{\left( {y - 0.5} \right)^{2}}{\sigma^{2}}} \right)} + {\exp\left( {- \frac{\left( {y + 0.5} \right)^{2}}{\sigma^{2}}} \right)}}$

is a penalty loss that is maximal at magnitude 0.5. The extent of thepenalty can be adjusted with the σ parameter, which becomes a tunablehyperparameter.

5.4.3 Split Quantisation and Soft-Split Quantisation

Having visited the effects of STE quantisation, we recognise that thenegative impact stem from the entropy gap, or in other words due to thefact that the probability model is discretised. In fact, training withSTE achieves much lower reconstruction losses than training with noisequantisation proxies, indicating that the decoder ƒ_(dec) seems tobenefit from being aware of the true quantised variables.

Since we have distinguished two separate components for thediscretisation gap (FIG. 35 for example), one with respect to the rateloss and one with respect to the distortion loss, we can assigndifferent quantisation proxies for each one. In order to avoid gradientissues when discretising the entropy model, we use noise quantisation{tilde over (Q)}_(R)(y_(i))=y_(i)+ε_(i)={tilde over (y)}_(i) ^([R]),ε_(i)˜

(−0.5, +0.5) for the rate component of the quantised latents. For thedistortion component of the quantised latents, we leverage truequantisation in the forward function and override the backward functionwith a differentiable straight-through estimator,

${{{\overset{\sim}{Q}}_{D}\left( y_{i} \right)} = {\left\lfloor y_{i} \right\rceil = {\overset{\sim}{y}}_{i}^{\lbrack D\rbrack}}},{\frac{\partial{\overset{\sim}{Q}}_{D}}{\partial_{y_{i}}} = {1.}}$

We call this quantisation scheme split quantisation. Whilst thediscretisation gap remains open for the rate loss, the distortiondiscretisation gap is effectively closed. On the flip side, this alsointroduces a gradient gap for {tilde over (Q)}_(D).

We can address the issue of the new gradient gap for {tilde over(Q)}_(D) by simply rerouting the gradient signal through {tilde over(Q)}_(R)(y_(i)) instead using detaching (or stop-gradient) operations.These exist in automatic differentiation packages which breaks thegradient flow through the detached quantities. With this knowledge, weintroduce the soft-split quantisation {tilde over (Q)}_(SS):

{tilde over (Q)} _(SS)(y _(i))=detach({tilde over (Q)} _(D)(y_(i))−{tilde over (Q)} _(R)(y _(i)))+{tilde over (Q)} _(R)(y_(i))  (5.19)

Now, since the gradients are flowing through the rate quantisationproxy, which has a closed gradient gap, we have successfully closed thediscretisation gap for the distortion without yielding negativeside-effects.

Schematics for both split quantisation and soft-split quantisation canbe seen in FIG. 43 .

5.4.4 QuantNet

Mathematically, the derivative of a true quantisation function is zeroalmost everywhere and infinity at quantisation boundaries. Hence, thisprevents us from using automatic differentiation packages to compute itsgradient for further backpropagation. However, since most truequantisation functions can be seen as non-linear operators, we canassign a differentiable neural network ƒ_(QN) to simulate the task ofthe true quantisation function, which we call QuantNet. By supervisingit to output the truly quantised variables ŷ=ƒ_(QN)(y)≈ŷ, we couldleverage its differentiability to backpropagate signals through thequantisation operation.

For each set of latents y, we compute the non-differentiable truequantised latents using, for instance, a rounding function ŷ=└y┐. Then,we supervise the QuantNet with a regularisation term (a norm-distance ofdegree p, which is the user's input choice) from the ground-truthquantised variables

_(QN)=∥ƒ_(QN)(y)−ŷ∥ _(p)  (5.20)

which we minimise jointly with the standard rate-distortion objective(Equation (5.1)). As a result, the QuantNet is trained to output thetrue quantised variables which can be used or further propagationthrough the decoder and entropy model. In order to avoid the networkfrom cheating (for instance by setting the QuantNet to the identityfunction which would in effect imply no quantisation), theregularisation term has to be appropriately scaled to enforce theintended behaviour of QuantNet.

The architectural details are not specific to this innovation, and canbe arbitrarily composed by traditional deep learning operations (linearlayers, convolution layers, activation functions, etc.). From thestandpoint of the quantisation gaps, QuantNet attempts to narrow the gapof the discretisation gap and entropy gap, and definitely close thegradient gap thanks to its differentiability.

Variations and alternative strategies of QuantNet-based quantisationinclude, but are not limited to:

-   -   ƒ_(QN) can be pre-trained in isolation on arbitrary data to        learn the quantisation mapping. After retaining a sufficiently        high accuracy, we can slot the network into our autoencoder        model and freeze its parameters, such that they will not get        updated with optimiser steps (gradients will just flow through        backwards).    -   ƒ_(QN) can be initialised at beginning of network training of        the original autoencoder, but optimised separately in a two-step        training process. After a full forward and backward propagation,        firstly the parameters for the autoencoder are updated with the        first set of optimisation configurations. Then, the parameters        of the QuantNet (and, optionally, the encoder in addition to        allow for more “quantisation-friendly” inputs) are optimised        with its own set of optimisation configurations. This allows for        better control of the balance between the necessities of the        autoencoder (minimising rate and distortion) and the QuantNet        (actually producing quantised outputs).    -   The QuantNet can also be designed so as to predict the        quantisation residuals rather than the quantised variables        themselves, {tilde over (ε)}=ƒ_(QN)(y). The functional        expression then becomes {tilde over (y)}=y+ƒ_(QN)(y), akin to a        residual connection. The advantages of this is two-fold: a)        {tilde over (ε)} can be more easily restricted to output values        limited to the range of actual quantisation variables (such as        [−0.5, +0.5]), and b) the gradients from the distortion loss do        not have to flow through the QuantNet which otherwise may render        the gradients uninformative; instead, they flow directly to the        encoder.    -   The regularisation term can also be extended to incorporate        generative losses, such as a discriminator module trained to        separate between real and fake quantisation residuals.

FIG. 44 shows an example of a flow diagram of a typical setup with aQuantNet module, and the gradient flow pathways. Note that truequantisation breaks any informative gradient flow.

5.4.5 Learned Gradient Mapping

The learned gradient mapping approach can be seen as being related tothe QuantNet concept. In contrast to parametrising a network to computethe forward function (and its derivative), this approach utilises thechain rule (Equation (5.4)) to parametrise and learn an alternativegradient function

$\frac{\overset{\sim}{\partial Q}}{\partial y} \approx \frac{\partial\overset{\hat{}}{y}}{\partial y}$

of a true quantisation operation ŷ=Q(y). It can be seen as thegeneralisation of STE quantisation with a learned overriding functioninstead of the (fixed) identity function.

A flexible way of learning a gradient mapping is by using a neuralnetwork ƒ_(GM):

$\left. \frac{\partial\mathcal{L}}{\partial\overset{\hat{}}{y}}\mapsto\frac{\partial\mathcal{L}}{\partial y} \right.$

and optimise over its parameters. If the quantisation gradient

$\frac{\partial\overset{\hat{}}{y}}{\partial y}$

a can be appropriately learned, this innovation contributes to closingthe gradient gap for STE quantisation proxies (since in the forwardpass, we would be using true quantisation).

There exists at least two possible ways of training ƒ_(GM):

-   -   1. Simulated annealing approach: This method relies on        stochastic updates of the parameters of ƒ_(GM) based on an        acceptance criterion. Algorithm 5.1 demonstrates an example of        such an approach.    -   2. Gradient-based approach: Similar to the previous method, but        purely utilising gradient descent. Since ƒ_(GM) influences the        encoder weights θ, the backpropagation flows through weight        updates Δθ(so second-order gradients) in order to update the        weights of ƒ_(GM), ψ.

5.4.6 Soft Discretisation of Continuous Probability Model

With a continuous relaxation for our probability model, the networkspends efforts to optimise for small perturbations in y. From theperspective of the forward function of quantisation, these perturbationsyield very little meaning since most of them get rounded away ininference. However, in network training, thanks to our rate formulation(Equations (5.11) and (5.12)), the probability mass evaluated differs bylarge margin from the actual probability mass assigned in inference,when we actually quantise (see upper two plots in FIG. 45 for example).This is also known as the entropy gap.

Algorithm 5.1 Simulated annealing approach of learning a gradientmapping for the true quantisation function. The parameters are perturbedstochastically and the perturbation causing encoder weight updates thatreduce the loss the most is accepted as the weight update for f_(GM). 1: Variables:  $\left. {\psi:{Parameters}{for}f_{GM}:\frac{\partial\mathcal{L}}{\partial\hat{y}}}\rightarrow\frac{\partial\mathcal{L}}{\partial y} \right.$ θ: Parameters for f_(ene): x 

 y (encoder)  2: for x in dataset do  3: ψ^([0]) ← ψ  4: θ^([0]) ← θ 5: 

^([0]) ← autoencoder(x, θ^([0]))  6: for k ← 1 to K do  7:  Δψ ← sample()

 Arbitrary random distribution  8:  ψ^([k]) ← ψ^([0]) + Δψ  9:  ψ ←ψ^([k]) 10:  θ ← θ^([0])

 Reset encoder weights to initial state 11:  backward(

^([0]))

 Backpropagate with ψ^([k]) which influences θ^([k]) 12:  optimise(θ)

 Gradient descent step for θ 13:  

^([k]) ← autoencoder(x, θ) 14: end for 15: k_(min) ← arg min_(k){

^([0]),

^([1]), . . . ,

^([K])} 16: ψ ← ψ^([k) ^(min) ^(])

 Update parameters for f_(GM) 17: θ ← θ^([0]) 18: backward(

^([0])) 19: optimise(θ) 20: end for

We can counteract this effect by utilising more “discrete” densitymodels, by soft-discretising the PDF to obtain less “smooth” continuousrelaxation, such that the entropy gap can be reduced between trainingand inference. See the lower two plots in FIG. 45 , for example, for avisualisation.

5.4.7 Context-Aware Quantisation

Since quantisation affects both the rate and distortion terms, it has amajor impact on the optimisation task. However, in most cases, we setthe bin widths Δ to be constant for all the elements that we quantise.This makes an implicit assumption that every element has the samesensitivity to quantisation errors. We have established that this isunlikely to be the ideal case. For instance, if a certain element y₁ ismore sensitive to small perturbations than other elements y₂, then wewould ideally like its error magnitude |ε(y₁)|=|Q (y₁)−y₁|∈ [0, Δ₁] tobe smaller in general than the error magnitude of the latter|ε(y₂)|=|Q(Y₂)−y₂|∈[0, Δ₂]. This is achieved by reducing the bin widthof the former with respect to the latter element, Δ₁<Δ₂.

Inspired by traditional compression whose main source of lossiness stemsfrom the coarseness of the quantisation, we provide a learned method ofcontext-aware quantisation for which Δ is predicted or optimised for. Itcan be an add-on to (uniform) noise quantisation, for which Δ_(i)=1.0normally for integer quantisation, on top of which we provide thefollowing enhancements:

-   -   1. Making Δ_(i) learnable (of any granularity: element, channel        or layer) such that the quantisation proxy becomes

$\begin{matrix}{{\overset{\sim}{Q}\left( y_{i} \right)} = {y_{i} + \varepsilon_{i}}} & {\varepsilon_{i} \sim {\mathcal{U}\left( {{- \frac{\Delta_{i}}{2}},\ {+ \frac{\Delta_{i}}{2}}} \right)}}\end{matrix}$

and the true quantisation function becomes

$\left. {{Q\left( y_{i} \right)} = \left\lfloor \frac{y_{i}}{\Delta_{i}} \right.} \right\rceil\Delta_{i}$

and then take into account the bin widths in the rate estimation.Optimise for Δ_(i) or its precursor during training.

-   -   -   Example: Assume we make the vector δ∈            M for our latent space            ^(M), and truncating its values within [−1, 1] (using a            clamping or the hyperbolic tangent operation). A could be            parametrised by choosing a positive base b, and compute            Δ=b^(δ). This approach maintains the elements within a            fixed, positive bounds,

${\Delta \in \left\lbrack {\frac{1}{b},\ b} \right\rbrack^{M}}.$

-   -   2. Similar to the previous point, but with the addition of        encoding the metainformation regarding Δ_(i). This could be        achieved through the usage of for instance a hyperprior, or a        similar construct.    -   3. Transforming the latent space (or partitions of the space)        into a frequency domain with a bijective mapping T:        ^(M)→        ^(M). This mapping T can be (a) fixed, using known discrete        frequency bases such as discrete cosine transforms, discrete        Fourier transforms, or discrete wavelet transforms etc., (b)        learned using either the Householder transformation (since a        bijective linear mapping constitutes an orthonormal basis)        or (c) parametrised (and learned) using normalising flows. Then,        in the transformed space, the latents are quantised with learned        bin sizes A, each element of which pertains to a frequency band.        -   Example: Suppose the latent space is partitioned into B            contiguous blocks of size L, and let us consider one such            blocks, y^([b])∈            ^(L), ∀b∈{1, . . . , B}. We then transform this partitioned            vector with an orthogonal basis matrix M ∈            ^(L×L) into the transformed space,            T(y^([b]))=My^([b])=z^([b]). In this space, the transformed            vector is quantised with learned bin sizes {circumflex over            (z)}^([b])=Q(z^([b]), Δ) and the rate loss is evaluated (or            the bitstream is coded). Subsequently, the inverse            transformation T⁻¹ is applied on the quantised transformed            vector to retrieve ŷ^([b])=T⁻¹({circumflex over            (z)}^([b]))=M^(T){circumflex over (z)}^([b]).

Note that this method does not necessarily aim to close any of the threegaps of quantisation. Rather, its goal is to assist in theparametrisation of the entropy model, of which quantisation is closelylinked, to achieve lower bitrates in the compression pipeline.

5.4.8 Dequantisation

We have seen multiple cases of where dealing with discrete valuesencumbers gradient-based optimisation approaches such as gradientdescent. However, the task of compression, in particular the inevitablequantisation process within it, is inherently a discrete one. Hence,there is interest in bridging the gap between the discrete andcontinuous spaces, and one effective way of doing so is throughdequantisation. This is the process of producing a continuousdistribution of an inherently discrete one (so a kind of quantisationinverse), which can be modelled with a continuous density model.

This concept has strong applicability in areas where a continuousdensity model (such as our entropy model) is necessary. Differentdequantisation methods impose different assumptions of the underlyingdiscrete model. For instance, adding independent uniform noise todequantise discrete variables imply no assumptions of the dependencybetween the underlying variables. This is the most naïve form ofdequantisation; in reality, for the case of latent variables exhibitingstrong spatially local dependencies, quantisation residuals are stronglycorrelated. Therefore, it makes sense to incorporate more sophisticateddequantisation techniques that can support more realistic continuousprobability models.

Some of the dequantisation techniques that we consider in ourinnovations include, but are not limited to:

-   -   Uniform dequantisation    -   Gaussian dequantisation    -   Renyĺ dequantisation    -   Weyl dequantisation    -   Regularised dequantisation    -   Autoregressive dequantisation    -   Importance-weighted dequantisation    -   Variational dequantisation with flow-based models    -   Variational dequantisation with generative adversarial networks

5.4.9 Minimising Quantisation Error with Vector-Jacobian Products

Intuitively, one may associate the minimisation of quantisationresiduals to having the least adverse effect on the compressionoptimality. However, due to the highly non-convex nature of neuralnetworks, this is not necessarily true. Rather, we have establishedtheory that the that the minimisation of the adverse effects ofquantisation on the global loss definition of compression (Equation(5.1)) is related to minimising second-order effects on the quantisationresiduals.

The theory that underpins this assertion can be derived by assuming thatthe loss term is a function of the input vector x and a feature (latent)vector y,

(x, y). Then, given a (discrete) perturbation on the feature vector, Δy,we would like to minimise the following:

[

(x y+Δy)−

(x, y)]  (5.21)

Expanding Equation (5.21) using the second-order Taylor seriesapproximation, we obtain

$\begin{matrix}{{\mathbb{E}}\left\lbrack {{{\Delta y}^{T} \cdot {\nabla_{y}{\mathcal{L}\left( {x,y} \right)}}} + {\frac{1}{2}\Delta{y^{T} \cdot {\nabla_{y}^{2}{\mathcal{L}\left( {x,y} \right)}} \cdot {\Delta y}}}} \right\rbrack} & (5.22)\end{matrix}$

where we can denote for the expected value of the loss gradient vectorand Hessian matrix with respect to y:

g _(y)=

[∇_(y)

(x, y)]  (5.23)

H _(y)=

[∇_(y) ²

(x, y)]  (5.24)

The loss gradient g_(y) is computable through automatic differentiationpackages (through vector-Jacobian product computation). Although theHessian H_(y) is also retrievable in the same way, the Hessian is anorder of complexity larger than the gradient, and may not be feasible tocompute. However, we can often evaluate Hessian-vector (orvector-Hessian) product directly with automatic differentiation tools,circumventing the issue of storing the Hessian matrix explicitly.Nevertheless, we may also use techniques to approximate the Hessian,such as

-   -   Second-order finite difference methods;    -   Broyden-Fletcher-Goldfarb-Shanno (BFGS) algorithm;    -   Limited-memory BFGS (L-BFGS) algorithm;    -   Other quasi-Newton algorithms.

Example: Assume we have a fully trained network and that a set ofunquantised latents y with corresponding data point x minimises a lossfunction

(x, y). Instead of rounding to the nearest integer, we optimise for thequantisation perturbation Δy that has the least impact on the loss value

$\begin{matrix}{\overset{\hat{}}{y} = {y + {\underset{\Delta y}{\arg\min}\Delta y^{T}H_{y}\Delta y}}} & (5.25)\end{matrix}$

where the loss gradient is ignored since it theoretically evaluates tozero for a fully trained network. Here, each set of element in Δy arechosen such that each y_(i) is either rounded up or down:

Δy _(i) ∈{└y _(i) ┘−y _(i) ,┌y _(i) ┐−y _(i)}  (5.26)

This turns the optimisation task defined in Equation (5.25) into aquadratic unconstrained binary optimisation problem; an NP-hard problem,unluckily. However, there exist methods that we could use to approximatethe global solution to Equation (5.25), for instance using AdaRoundwhich turns the optimisation into a continuous optimisation problem withsoft quantisation variables.

5.4.10 Quantisation in Parameter Space

Up until now, we have assumed that the quantisation is performed infeature space, in particular the latent space in which vectorsultimately get encoded and transmitted. However, all forms ofquantisation, both introduced as known in the introduction sections aswell as our innovations within this field, are similarly applicable inthe quantisation of parameter space. This is particularly in theinterest of low-bit network architecture, for which low-bit networkquantisation plays an important role. It is also useful for innovationsinvolving the transmission of quantised network parameters included inthe bitstream, which is employed for instance in finetuning processes.Hence, our advances do not solely pertain to quantisation in featurespace, but similarly in parameter space.

5.5 Concepts

In this section, we present the following concepts regardingquantisation, both scalar and vector quantisation considered, in bothfeature and parameter space for AI-based data compression with detailsoutlined in the referenced sections. All concepts listed below areconsidered under the context of quantisation in the wider domain ofAI-based data compression.

Section 5.4.1, “Eliminating Gradient Bias with Laplacian Entropy Model”

-   -   Application of entropy models of distributions families with        unbiased (constant) gradient rate loss gradients to        quantisation, for example the Laplacian family of distributions,        and any associated parametrisation processes therein.

Section 5.4.2, “Twin Tower Regularisation Loss”

-   -   Application of mechanisms that would prevent or alleviate the        twin tower problem, such as adding a penalty term for latent        values accumulating at the positions where the clustering takes        place (for integer rounding, and for STE quantisation proxies,        this is at −0.5 and +0.5).

Section 5.4.3, “Split Quantisation and Soft-Split Quantisation”

-   -   Application of split quantisation for network training, with any        arbitrary combination of two quantisation proxies for the rate        and distortion term (most specifically, noise quantisation for        rate and STE quantisation for distortion);    -   Application of soft-split quantisation for network training,        with any arbitrary combination of two quantisation proxies for        the rate and distortion term (most specifically, noise        quantisation for rate and STE quantisation for distortion),        where either quantisation overriding the gradients of the other        (most specifically, the noise quantisation proxy overriding the        gradients for the STE quantisation proxy).

Section 5.4.4, “QuantNet”

-   -   Application of QuantNet modules, possibly but not necessarily        parametrised by neural networks, in network training for        learning a differentiable mapping mimicking true quantisation,        with associated loss (regularisation terms) that actively        supervises for this behaviour;    -   Application of variations of QuantNet modules in terms of        functional expression, for example learning the quantisation        residuals, and in terms of training strategies such as        pre-training or two-stage training processes;    -   Application of other types of loss functions such as generative        (adversarial) losses.

Section 5.4.5, “Learned Gradient Mapping”

-   -   Application of learned gradient mappings, possibly but not        necessarily parametrised by neural networks, in network training        for explicitly learning the backward function of a true        quantisation operation;    -   Application of any associated training regime to achieve such a        learned mapping, using for instance a simulated annealing        approach or a gradient-based approach, or any other strategy        that would achieve the intended effect.

Section 5.4.6, “Soft Discretisation of Continuous Probability Model”

-   -   Application of more discrete density models in network training,        by soft-discretisation of the PDF or any other strategy that        would achieve the intended effect.

Section 5.4.7, “Context-Aware Quantisation”

-   -   Application of context-aware quantisation techniques, which        include learnable noise profiles for noise quantisation proxies        in training and commensurate quantisation bin widths employed        during inference and deployment;    -   Application of any parametrisation scheme for the bin width        parameters, at any level of granularity (elements, channel,        layer), including any form of encoding strategy of the        parametrisation as metainformation;    -   Application of context-aware quantisation techniques in a        transformed latent space, achieved through bijective mappings        such as normalising flows or orthogonal basis transforms that        are either learned or fixed.

Section 5.4.8, “Dequantisation”

-   -   Application of dequantisation techniques for the purpose of        modelling continuous probability distributions out of discrete        probability models;    -   Application of dequantisation techniques for the purpose of        recovering the quantisation residuals through the usage of        context modelling or other parametric learnable neural network        module, both in training and in inference and deployment.

Section 5.4.9, “Minimising Quantisation Error with Vector-JacobianProducts”

-   -   Application of the modelling of second-order effects for the        minimisation of quantisation errors, both during network        training and in post-training contexts for finetuning purposes;    -   Application of any arbitrary techniques to compute the Hessian        matrix of the loss function, either explicitly (using finite        difference methods, BFGS or quasi-Newton methods) or implicitly        (by evaluating Hessian-vector products);    -   Application of adaptive rounding methods (such as AdaRound that        utilises the continuous optimisation problem with soft        quantisation variables) to solve for the quadratic unconstrained        binary optimisation problem posed by minimising the quantisation        errors.

6. Exotic Data Type Compression 6.1 Introduction

The end-to-end AI-based Compression pipeline usually gets applied tostandard format images (single images of arbitrary resolution) andvideos (single videos of arbitrary resolution). However, this limits thetrue potential of the end-to-end based principle that the AI-basedCompression pipeline pioneers. Here we describe the usage of AI-basedCompression on specific data types and for specific markets and showhow, and why, AI-based Compression is ideally suited for exotic datatype compression.

Specifically, we will look at the extension of the AI-based Compressionpipeline for:

-   -   Stereo-image data (e.g. VR/AR data, depth-estimation)    -   Multi-view data (e.g. self-driving cars, image/video stitching,        photogrammetry)    -   Satellite/Space data (e.g. multispectral image/videos)    -   Medical data (e.g. MRI-scans)    -   Other image/video data with specific structure

There are numerous exotic data types for which traditional compressionapproaches (non-end-to-end learned techniques, e.g. JPEG, WebP, HEIC,AVC, HEVC, VVC, AV1) do not work. This is because of three reasons:First, the traditional compression methods have long, costly developmentprocesses with a lot of hand-crafting and human input required. Thus,exotic data compression is not a sufficiently big market to justifydeveloping a stand-alone compression approach. Second, the exotic datatypes often come with a “specific” structure that could be exploited forbetter compression, but this structure is too complex and challenging tomodel for the traditional compression approaches. Third, the exotic dataoften requires different optimisation criteria than compression wrt“pleasing visual images/videos”. E.g. for medical data, the visualaspect is less relevant compared to the accuracy of medicalpost-processing algorithms that use the compressed data as input. Giventhese difficulties, until now, there exist only general-purposecompression codecs without specialised sub-codecs. If “sub-codecs”exists, they are often naively-applied traditional methods without anyspecialisation or modifications.

In contrast to the traditional compression techniques, the AI-basedCompression pipeline is an end-to-end learnable coded based on neuralnetworks. As neural networks are universal function approximators, theAI-based Compression can, theoretically, model any dependencies as longas sufficient training data with these structures are given. Also:

-   -   1. Changing the AI-based Compression pipeline to different input        data can be achieved by creating a new dataset and retraining        the neural networks.    -   2. Modelling different and challenging structures in the        AI-based Compression pipeline can be achieved by modifying its        neural architecture.    -   3. Modelling for other objectives than “visual quality” can be        achieved by changing the pipeline/neural network's loss        function.

Thus, the AI-based Compression is ideally suited to not only create abetter general-purpose compression codec but to create numeroussub-codecs that, for the first time, can compress exotic data optimally.In general, these techniques can be extended to arbitrary image andvideo related exotic data.

6.2 Stereo Data Compression

In video compression, we have input across the temporal domain, x_(1,t)and x_(1,t+1), and have temporal constraints on the data: x_(1,t+1) willdepend in x_(1,t). The temporal constraints are motion-constraints andcome from prior knowledge how things move in the time direction.

In stereo data compression, we have two input images or videos, x_(1,t)and x_(2,t), at the same temporal position. Additionally, if the data'sviewpoints overlapped to any degree or have overlapped in the past, thestereo data has spatial constraints given by its common (3D) viewpoint.

Compression can be just another word for redundancy reduction. Stereodata compression aims to use these spatial constraints to lower theentropy/filesize by using the given spatial constraints to reduceinformation. Thus, it is crucial that AI-based Compression processes andentropy-encodes x_(1,t) and x_(2,t) simultaneously using their jointprobability distribution P_((x) ₁ _(, x) ₂ ₎ (omitting index t). Notethat this is different to video compression where we require theirconditional probability function P_((x) _(t+1) _(|x) _(t) ₎ or singleinput compression using P_(x) ₁ .

The AI-based compression pipeline's extension to model stereo data is togive both as input data for the neural network (→early fusion); FIG. 46& FIG. 47 illustrates these modifications. Additionally, the compressionformulation naturally extends to stereo data. Let (x₁, x₂) be the inputdata, y be the bottleneck latent space and p(·) be the ground-truthdistributions (unknown) and q(·) be our approximate distributions.Minimising the KL divergence of the posterior distribution is equivalentto: In a compression with input x:

${{\mathbb{E}}_{x_{1}\sim p_{x_{1}}}\left\lbrack {p_{y{❘x_{1}}}{q_{y{❘x_{1}}}}} \right\rbrack} \propto {{\mathbb{E}}_{x_{1}\sim p_{x_{1}}}\left\lbrack {{\mathbb{E}}_{y\sim p_{y}}\left\lbrack {\underset{Distortion}{\underset{︸}{\left. \left. {{- \log}\left( {q_{x_{1}{❘y}}\left( {x_{1}{❘y}} \right.} \right.} \right) \right)}}\underset{Rate}{\underset{︸}{{- \log}\left( {q_{y}(y)} \right)}}} \right\rbrack} \right\rbrack}$

In stereo compression with input (x₁, x₂):

$\begin{matrix}{{{\mathbb{E}}_{{({x_{1},x_{2}})}\sim p_{({x_{1},x_{2}})}}\left\lbrack {p_{y{❘{({x_{1},x_{2}})}}}{q_{y{❘{({x_{1},x_{2}})}}}}} \right\rbrack} \propto} \\{{\mathbb{E}}_{{({x_{1},x_{2}})}\sim p_{({x_{1},x_{2}})}}\left\lbrack {{\mathbb{E}}_{y\sim p_{y}}\lbrack{\underset{Distortion}{\underset{︸}{\left. {{- \log}\left( {{q_{{({x_{1},x_{2}})}{❘y}}\left( {x_{1},x_{2}} \right)}{❘y}} \right)} \right)}}\underset{Rate}{\left. \underset{︸}{{- \log}\left( {q_{y}(y)} \right)} \right\rbrack\rbrack}}} \right.}\end{matrix}$

6.2.1 the Loss Function

Compression relates to the rate-distortion trade-off: a distortion termthat models human perception vision and a rate term that models thefilesize.

However, in stereo-image compression, there is a high likelihood that weare not only interested in the visual quality of output {circumflex over(x)}₁ and {circumflex over (x)}₂, but also care about keeping theintegrity of the 3D-viewpoint. For instance, Stereoscopy (in VR)requires more constraints than just the visual quality of {circumflexover (x)}₁ and {circumflex over (x)}₂. Stereoscopy also requires thatthe re-projection of the 2d-plan into the 3d-world is consistent, aka.that the depth information encoded between {circumflex over (x)}₁ and{circumflex over (x)}₂ is (sufficiently) accurate.

To model this constraint, the AI-based Compression pipeline requires andadditional (differentiable) loss term; FIG. 48 illustrates an example ofthis add-on. Possible loss terms are:

-   -   1. Single image depth-map estimation of x₁, x₂, {circumflex over        (x)}₁, {circumflex over (x)}₂, and then measuring the distortion        between the depths maps of x₁, {circumflex over (x)}₁ and x₂,        {circumflex over (x)}₂. For single-image depth map generation we        can use Deep Learning methods such as self-supervised monocular        depth estimation or self-supervised monocular depth hints. For        distortion measures, we can use discriminative distance measures        or generative metrics.    -   2. A reprojection into the 3-d world using x₁, x₂ and one using        x{circumflex over (x)}₁, {circumflex over (x)}₂ and a loss        measuring the difference of the resulting 3-d worlds        (point-cloud, vortexes, smooth surface approximations). For        distortion measures, we can use discriminative distance measures        or generative metrics.    -   3. Optical flow methods (e.g. DispNet3, FlowNet3) that establish        correspondence between pixels in x₁, x₂ and x{circumflex over        (x)}₁, {circumflex over (x)}₂ and a loss to minimise these        resulting flow-maps. For flow-map distortion measures, we can        use discriminative distance measures or generative metrics.

6.2.2 Other Considerations

Another observation is that with a stereo-camera setting, we have a newtype of metainformation that can be helpful: The positional locationinformation of the cameras/images and their absolute/relativeconfiguration. For instance, in Stereoscopy the baseline, the FoV(field-of-view), sensor-type, resolution, and other metainformation isinvaluable.

For stereo data compression, we can either have our neural networkencode this information as a prior through the training process. Or wecan explicitly feed this information into our neural network througharchitecture modification. For instance, we can bring the metadata tothe same resolution as the image/video data through processing withfully connected layers and then concatenate it to the inputs (x₁, x₂)and to the bottleneck latent y. FIG. 49 illustrates an example of thisstep.

If we use early fusion in the compression pipeline, it also makes senseto provide the ground-truth dependencies between x₁ and x₂ as additionalinput. This is crucial as a more proper modelling of thejoint-probability function of x₁ and x₂ is a conditional jointdistribution given the spatial restrictions and dependencies. E.g. usingP_((x) ₁ _(, x) ₂ _()|spatial-restriction-data) is a much better modelto reduce entropy than simply using P_((x) ₁ _(, x) ₂ ₎. For example: Ifwe have access to the depth-maps; or approximate the actual depth mapsvia advanced algorithms, e.g. DispNet3, we can use it as additional,helpful input. The input to our Encoder gets extended from (x₁, x₂,camera-data) to (x₁, x₂, camera-data, spatial-restriction-data), withspatial-restriction-data being the depth-map, optical-flow or otheruseful data.

6.3 Multi-View Data Compression

Multi-view data is the natural extension of stereo-data to a morecomplex setting. Instead of x_(1,t) and x_(2,t), we now have N inputimages/video {x_(1,t), x_(2,t), . . . , x_(N,t)} that might come fromdifferent devices with different settings. Good examples include2D-to-3D, Photogrammetry, Self-driving cars, SLAM-applications, (online)visual odometry, 360°-video (can be interpreted as multi-view data), n-Dsimulation, 360°-images/videos on a website, panoramic images/videos,and others.

Each of these examples has its unique constraints, which if we canphrase as a differentiable loss function, we can incorporate in theAI-based Compression pipeline. Suppose we can not express theconstraints into a differentiable loss function. In that case, we canstill use either a proxy network similar to “QuantNet” or “VMAF Proxy”and/or can use reinforcement learning techniques to model it.

If we have data that does not come from the same sensors, e.g. inself-driving cars, the camera sensors around the vehicle can vary; itmakes sense to use pre-processing layers to bring all data into the samefeature space. FIG. 50 illustrates an example of this extension to theAI-based Compression pipeline.

6.3.1 Other Considerations

In stereo data compression, we have spatial constraints, usually givenby a common 3-D viewpoint. In video compression, we have temporalconstraints, traditionally given by motion-vectors andmotion/acceleration/momentum restrictions. In multi-view data(especially multi-view video), we tend to have both of theseconstraints.

Suppose we have a self-driving car with eight cameras at the top-left,top, top-right, middle-left, middle-right, bottom-left, bottom-middle,bottom-right. At the same time, t, some of these cameras will haveoverlapping viewpoints from a common 3D-scene and thus, have spatialconstraints. However, some of the cameras will not have a common3D-scene at t (e.g. top-right and bottom-right). FIG. 51 visualises anexample. However, if the car continues to move forward, at some time(t+i), the 3D-scene that the bottom right camera is capturing will havea spatial-temporal constraint from a previous frame captured by thetop-right camera. Thus, multi-view video data is, in some sense, thecombination of spatial and temporal constraints that can be exploitedfor redundancy reduction/compression.

If we know the approximate rate at which different temporal data leadsto spatial constraints, we can use this prior as helpful information inthe AI-based Compression pipeline. There are three ways to do so: First,we use x_(2,(t+i)) and x₂,(t+i) as input, if we know that the past frameat t from camera 1 spatially constraints the current frame at (t+i) fromcamera 2. Second, we include multiple spatial and temporal inputs andindicate video meta-information, which inputs tie to each otherspatially. Finally, we can keep a queue of bottleneck-layers {ŷ_(1,t), .. . , ŷ_(n,t); ŷ_(1,t+1), . . . , ŷ_(n,t+1); . . . ; ŷ_(1,t+i), . . . ,ŷ_(n,t+i)} and model which inputs tie to each other spatially on theentropy-level. FIGS. 52, 53, 54 illustrate examples of these options.

Note that FIG. 53 is an example of a human-designed form of arestriction. Instead of using human-designed input data that the networkcan use, we could also provide additional data about the 3-D viewpointand let the network figure out these restrictions by itself. We couldprovide multi-view depth maps (ground-truth or learned) and or opticalflow data as additional input. Like the stereo case, the multi-view casewill benefit from the auxiliary input data by better conditioning theprobability model to its restricted input.

6.4 Satellite/Space Data Compression

Satellite image and video sensors usually capture more spectral bandsthan just the visual spectrum. Thus, instead of the standard format of a3-channel image/video, we get n-channel image/video with each channelrepresenting a particular band (different wavelengths).

This data type can be seen as a particular case of multi-view data. Theviewpoints all overlap, but we get different information about thescene, like having various camera sensors with variable calibrationdata. Thus, all previously mentioned methods for stereo-data andmulti-view data apply, too.

However, in addition to the previous cases, satellite data often comeswith an objective which is not primarily scene quality but there areclassification or segmentation questions. For instance: Atmosphereforecasting and monitoring, weather predictions, event classification,detection of geological or human events, agriculture monitoring,military purposes, and many others. This provides the opportunity tocompress spectral data with a non-visual based loss term for distortionbut an event-driven loss based on the exact question that we want toanswer. Also, this is not limited to one auxiliary loss but can easilyextend to n-auxiliary losses.

Suppose we have satellite data and want to monitor a forest's health anddetect oil spills (dual objective). Instead of only having the visualquality as the distortion term, we can model the data-post processingmethods' accuracy. Let's assume we have a spectral-image/video algorithmto detect oil spills O(x) and an algorithm to monitor forest health F(x)with some distortion metric D(·). Our satellite data compressionobjective for input data x with n-channels becomes:

$\begin{matrix}{\left. {{\mathbb{E}}_{x\sim p_{x}}\left\lbrack {p_{y{❘x}}{q_{y{❘x}}}} \right.} \right\rbrack \propto} \\{{\mathbb{E}}_{x\sim p_{x}}\left\lbrack {{\mathbb{E}}_{y\sim p_{y}}\left\lbrack {{\underset{{{Image}/{Video}}{Quality}{Distortion}}{\underset{︸}{\left. \left. {{- \log}\left( {q_{x{❘y}}\left( {x_{1}{❘y}} \right.} \right.} \right) \right)}}\underset{Rate}{\underset{︸}{{- \log}\left( {q_{y}(y)} \right)}}} + \underset{{Post} - {{Processing}{Losses}}}{\underset{︸}{{D\left( {{O(x)},{O\left( \overset{\hat{}}{x} \right)}} \right)} + {D\left( {{F(x)},{F\left( \overset{\hat{}}{x} \right)}} \right)}}}} \right\rbrack} \right\rbrack}\end{matrix}$

Using this approach in combination with AI-based Compression, we canquickly and cheaply design numerous neural networks specialised incompressing Satellite data with given objectives. Even better, we canswitch between different approaches easily. Let's assume we have acompression codec trained on forest-data monitoring, but after a week,we want to reprogram our Satellite for oil spill monitoring. In AI-basedCompression, having a codec specialised means having the network trainedon specific loss-terms and using the trained network parameters θ forinference. If we want to change our objective, we have to re-trainanother network, get another 0 optimised for our new goal, and replacethe neural network weights. This can all be done in software, with nohardware replacements and can be seen as “streaming a codec”—aninvaluable property of AI-based Compression. FIG. 55 illustrates anexample of these methods.

6.5 Medical Data Compression

Compression with medical data follows the same guidelines as mentionedin the Satellite/Space data section. Often, we have special image andvideo data (Saitellite==multi-band data; Medical: health-care scans),which will be the input for post-processing algorithms. Thus, we requiretraining over a particular input data training set, and the compressionobjective needs to be updated (→new θ).

The auxiliary loss terms can be, amongst others, related to:

-   -   Computer-aided detection/diagnosis (e.g., for lung cancer,        breast cancer, colon cancer, liver cancer, acute disease,        chronic disease, osteoporosis)    -   Machine learning post-processing (e.g., with support vector        machines, statistical methods, manifold-space-based methods,        artificial neural networks) applications to medical images with        2D, 3D and 4D data.    -   Multi-modality fusion (e.g., PET/CT, projection X-ray/CT,        X-ray/ultrasound)    -   Medical image analysis (e.g., pattern recognition,        classification, segmentation) of lesions, lesion stage, organs,        anatomy, status of disease and medical data    -   Image reconstruction (e.g., expectation maximization (EM)        algorithm, statistical methods) for medical images (e.g., CT,        PET, MRI, X-ray)    -   Biological image analysis (e.g., biological response monitoring,        biomarker tracking/detection)    -   Image fusion of multiple modalities, multiple phases and        multiple angles    -   Image retrieval (e.g., lesion similarity, context-based)    -   Gene data analysis (e.g., genotype/phenotype        classification/identification)    -   Molecular/pathologic image analysis    -   Dynamic, functional, physiologic, and anatomic imaging.

6.6 Concepts

-   -   1. Using AI-based Compression for Stereo Data (Stereo Images or        Stereo Video).    -   2. Using AI-based Compression for VR/AR-Data and        VR/AR-applications.    -   3. Using 3D-scene consistency loss objectives for stereo data        compression.    -   4. Using flow-based consistency loss objectives for stereo data        compression.    -   5. Using camera/sensor data as additional input data for        AI-based compression.    -   6. Using AI-based Compression for multi-data compression using        its joint probability density interpretation.    -   7. Using AI-based Compression for Multi-View Data (multi-view        images or Video).    -   8. Using multi-view scene constraints as an additional loss term        within AI-based Compression.    -   9. Using temporal-spatial constraints in AI-based Compression        via additional metainformation at the input or the bottleneck        stage.    -   10. Using AI-based Compression for Satellite and Space        image/video compression.    -   11. Using AI-based compression for stereo/multi-view on        Satellite/Space data.    -   12. The application of “streaming a codec”. E.g. upstreaming        NN-weights for quickly changing compression algorithm        specialisation using AI-based Compression.    -   13. Using AI-based Compression for Medical Image/video        compression.    -   14. Using medical auxiliary losses for post-processing        objective-detection.    -   15. Using AI-based compression on Medical data.

7. Invertible Neural Networks for Image and Video Compression 7.1Introduction

Learnt image and video compression is based on neural networks which arenon-invertible transformations. We provide multiple ways of integratingthe standard learnt pipeline with Invertible Neural Networks (INNs),also known as Normalising Flows, which are bijective mappings that canbe used to transform a random variable to an alternative representationand back. The bijective ability of INNs allows us greater flexibility inenforcing a prior distribution on the latent space, in addition toproviding a point of contact between adversarial and Maximum LikelihoodEstimation (MLE) training.

7.1.1 Change of Variable and Normalising Flows

Let us consider a random variable y∈

^(N). We can transform this variable using a mapping ƒ:

^(N)→

^(N) (it is important that the input space has the same dimensionalityas the output space). The probability distribution of the outputvariable z can then be calculated in terms of the probabilitydistribution on the input variable y, as shown below:

$\begin{matrix}{{p({\mathcal{z}})} = {{p(y)}{❘{\det\left( \frac{df^{- 1}}{dy} \right)}❘}^{- 1}}} & (7.1)\end{matrix}$

This formula has two requirements:

-   -   The determinant of the Jacobian matrix of the transformation

$\left( {.i.e.{}\frac{df}{d{\mathcal{z}}}} \right)$

must be defined, in other words the Jacobian matrix has to be square.This has important implications because it means that the normalisingflow can't change the dimensionality of the input.

-   -   The determinant has to be nonzero, otherwise its inverse in the        equation is undefined.

In order to satisfy both of these conditions, and thus to be able tocalculate the probability distribution of z in terms of the probabilitydistribution of y, the transformation ƒ needs to be invertible, hencethe need for an invertible neural network (although in order to bedefined as a normalising flow, the transformation is not required tocontain a neural network).

Why do we want to define the output distribution in terms of the inputdistribution?

Because our objective is to map a complex distribution (such as thedistribution of the latent space of our autoencoder when there is noentropy model enforced) to a simple distribution (such as a normal orlaplacian prior), so that we can enforce an entropy model on z whileretaining the spatial information in y that improves reconstructionquality.

In addition to the hard requirements listed above, there is one more“soft” requirement, that is, the determinant of the Jacobian matrix hasto be easy to compute. This is not the case for any matrix, so thecalculation can become expensive when the Jacobian matrix has a highrank, especially if we chain multiple transformations together in anormalising flow (a feat that is quite common to increaserepresentational power).

How can we make the determinant of the Jacobian easy to compute?

If the square matrix is upper- or lower-triangular, i.e. it has non-zeroelements as shown, for example, in FIG. 56 which shows an exampleincluding an upper triangular matrix form U and lower triangular matrixform L. Then the determinant is simply the product of the elements onthe diagonal.

7.1.2 how to Make Jacobian Matrix Triangular

We remind the reader that the Jacobian matrix of a mapping ƒ:

^(N)→

^(N) has the form shown in FIG. 57 .

I.e. it is an N×N matrix for an input x containing elements {x₁, x₂, . .. x_(N)} and an output containing elements {ƒ₁, ƒ₂, . . . ƒ_(N)}.

For simplicity, we will describe only the process by which to make thismatrix lower triangular, because making it upper triangular consists ina very similar process.

We introduce the concept of a coupling transformation that splits theinput x into two partitions x_(a) and x_(b). The output of the couplingtransformation is then:

z _(a) =x _(a)

z _(b) =g(x _(b) ,m(x _(a)))(7.2)

Where g and m are arbitrary functions.

In an additive coupling transformation, we define g as the arithmeticaddition, and m as a neural network. This results in the belowtransformation:

z _(a) =x _(a)

z _(b) =m(x _(a))+x _(b)  (7.3)

This transformation is both trivial to invert, and has a triangularJacobian.

If we want to retrieve x from z, we only need to apply the followingoperations:

x _(a) =z _(a)

x _(b) =−m(Z _(a))+z _(b)  (7.4)

It is important to note that the neural network transformation needs notbe inverted. This greatly simplifies the process, as standard neuralnetwork architectures are hard to invert.

Additionally, the form of the Jacobian is shown below:

$\begin{matrix}{J = \begin{bmatrix}I & 0 \\\frac{\partial f}{\partial x_{a}} & I\end{bmatrix}} & (7.5)\end{matrix}$

Not only this Jacobian is lower triangular, but its diagonal entries areall 1. Hence, the determinant of the Jacobian is 1, meaning that thecomputational cost of calculating it is O(1) for any kind of additivecoupling.

It should be noted that additive coupling is not the only invertibletransformation: there are such things as multiplicative or affinecoupling layers, where the mapping g is the element-wise multiplicationoperation, and the joint multiplication and addition operationrespectively.

7.1.3 Volume-Preserving Vs Non-Volume-Preserving Transformations

The additive coupling transformation is said to be a volume-preservingtransformation. This stems from the fact that the determinant is 1.Volume-preserving (VP) transformations generally have lowertransformational power than non-volume-preserving (NVP) ones, since theformers are prevented from making some eigenvalues bigger and otherssmaller, resulting in more variation with respect to some input elementsthan others.

Multiplicative and affine coupling transformations are non-volumepreserving. Let us consider an affine coupling:

Z _(a) =X _(a)

Z _(b) =X _(b) ⊙S(X _(a))+m(X _(a))  (7.6)

Where s is another arbitrary transformation that in practice is definedas a neural network.

The Jacobian of an affine layer is below:

$\begin{matrix}{J = \begin{bmatrix}I & 0 \\\frac{\partial f}{\partial x_{a}} & {{diag}\left( {s\left( x_{a} \right)} \right)}\end{bmatrix}} & (7.7)\end{matrix}$

Now, since the diagonal entries of this Jacobian are not all ones, thedeterminant of the matrix is not 1 anymore, instead being the product ofthe diagonal elements of the scaling transformation s.

7.1.4 Squeeze Layers and Factor-Out Layers

Here we describe two additional operations that we use in ournormalising flows.

The first operation is the squeeze layer. Although we previously statedthat the dimensionality of the input of a normalising flow cannot bedifferent from the dimensionality of the output, we can change thespatial resolution and the number of channels of the feature maps,provided that the total number of elements is unchanged. The change indimensions is actuated with a squeeze layer that changes thedimensionality of the input tensor R^(H×W×C) into R^(H/2×W/2×4C). Thisallows the convolutional layers in the neural networks inside thecoupling transformations to operate on different scales at differentstages in the normalising flow.

The squeezing operation reallocates pixels from the spatial dimensionsinto different channels using a checkerboard pattern. FIG. 58 shows anexample of a diagram of squeezing operation. Input feature map on left,output on right. Note, the output has a quarter of the spatialresolution, but double the number of channels.

The checkerboard pattern ensures that pixels that are spatially closeare allocated to pixels in different channels that have the same spatiallocation. This mitigates the distortion of spatial information, which isimportant for the convolutional layers.

The second operation we describe is the factor-out layer.

The factor-out operation splits the feature map in two parts along thechannel dimension (although it can also split the feature map in thespatial dimensions). Then, one part is passed as the input to the nextnormalising flow block, while the other part is passed directly to thefinal output of the pipeline.

This has two implications: firstly it reduces the computation that needsto be done, which can add up to a great amount given that normalisingflows must maintain the dimensionality of the input; and secondly, theloss function is distributed through the whole network, so gradients aredirectly passed from the loss to all blocks of the chain instead of thelast block only.

Finally, there is a trick that we can use to circumvent the limitationof not being able to change dimensionality: if we need to increase thedimensionality of the input, we can pad it with zero values, thusincreasing the dimensionality from H×W×C to H×W×C+D. The normalisingflow will then produce as output of the same dimensionality as thepadded input, that is H×W×C+D: note that this is larger than the actualinput size of H×W×C. We just showed this trick in the channel dimension,but we can just as easily apply it in the spatial dimension as well.

7.1.5 Flowgan

As the name suggests, FlowGAN is a generative model obtained bycombining a normalising flow and a GAN setup.

In a GAN setup there is a generator and a discriminator network. Theinput to the generator z is sampled from a prior distribution and thegenerator network transforms it to the underlying distribution of thetraining data, i.e. if the training data is natural images the generatorlearns a mapping from P(z) to the distribution of pixel colours innatural images, that we define as P(G(z)).

The discriminator network is a classifier trained on both the generatedimages and the real training images: its aim is to differentiate betweenthe training images and the images generated by the generator.Intuitively, when the discriminator is unable to properly classify thetwo classes of images, then the generator is outputting realistic imagesthat look like the training images.

This adversarial training strategy presents a problem: the losses of thetwo networks have poor interpretability. For example, there is nocorrelation between the loss of the generator and how realistic thegenerated images look, often requiring the addition of visual qualityscores to estimate it. This poor interpretability stems from the absenceof an explicit likelihood function in the density model, which in thecase of GANs is implicit (it has no clearly-defined density model forthe generated data y). Unfortunately, it is impossible to obtain anexplicit model of P(G(z)), because its density can't be defined in termsof P(z).

FlowGAN solves this problem by using a normalising flow as the generatornetwork. An example structure is illustrated in FIG. 59 .

Such a setup allows to train the generator in two ways: either withadversarial training, against the discriminator network; or directlywith Maximum Likelihood Estimation, using the change of variable formulain Equation (7.1).

Given discriminator losses ho (on the training images) and h′_(ϕ) (onthe images created by the generator), the complete training objective ofFlowGAN is below:

$\begin{matrix}{L = {{\min\limits_{\theta}\max\limits_{\phi}{{\mathbb{E}}_{y\sim P_{\theta}}\left\lbrack {h_{\phi}(y)} \right\rbrack}} - {{\mathbb{E}}_{y\sim P_{data}}\left\lbrack {h_{\phi}^{’}(y)} \right\rbrack} - {\lambda{{\mathbb{E}}_{y\sim P_{data}}\left\lbrack {\log{p_{\theta}(y)}} \right\rbrack}}}} & (7.8)\end{matrix}$

The first two terms in the equation above are the adversarial terms for“real” and “fake” images, that need to be maximised with respect to thediscriminator weights ϕ and minimised w.r.t. the generator weights θ (weremind the reader that the generator needs to fool the discriminatorinto classifying the fake images as real). The third term is thelikelihood of the training data, which is normally intractable in anadversarial setup; however, since the generator is an INN, we canexpress p(y) in terms of p(z) which has a tractable analyticaldistribution, so the likelihood is tractable in FlowGAN. The scaler Adetermines whether training is joint adversarial and MLE, or onlyadversarial (in the case where A is zero).

7.2 Innovation 7.2.1 Replacing Encoder and Decoder Transformations withINN

In this subsection we describe the substitution of both the encoder anddecoder networks with a single INN. The types of normalising flow layerswe use include (but are not limited to):

-   -   additive coupling layers;    -   multiplicative coupling layers;    -   affine coupling layers;    -   invertible 1×1 convolution layers.

FIG. 60 shows an example of a compression and decompression pipeline ofan image x using a single INN (drawn twice for visualisation purposes),where Q is quantisation operation and AE and AD are arithmetic encoderand decoder, respectively. Entropy models and hyperpriors are notpictured here for the sake of simplicity.

Using an INN instead of two networks results in an overall smaller sizeon computer disk which translates to faster transfer of the compressionpipeline over communication networks, facilitating the transfer offine-tuned codecs for specific sets of images or videos on-the-fly.

This pipeline is valid with a continuous flow, but it can be used withdiscrete flows as well with a small modification. In the case where acontinuous flow is used, the quantisation operation is necessary inorder to obtain a quantised latent space that can then be arithmeticcoded.

Now let us consider the case where a discrete flow is used. Discreteflows have a similar structure to continuous flows. For reference, weillustrate the architecture of the Integer Discrete Flow in FIGS. 61 and62 , by way of example.

The peculiarity of a discrete normalising flow is in its couplinglayers, where a quantisation operation is included (see below).

x _(a) =Z _(a)

x _(b) =└−m(z _(a))┐+z _(b)  (7.9)

Assuming a discrete input x, the output z will also be discrete, sincethe only possible source of non-discretised output is the neural networktransformation m, and that is explicitly quantised in the coupling layerabove. Thus, the quantisation operation described in the pipelineillustrated in FIG. 60 for example becomes unnecessary.

We also remind the reader that images are stored on computer disk usinginteger values, so they are already quantised before processing. Thischanges the compression pipeline from lossy to lossless, as the latentspace can be arithmetic coded as it is, because it is already discretewhen it is output by the integer normalising flow.

7.2.2 Integrating the HP with an INN to Map y to z where Entropy isComputed Over z

In addition to the pipelines described in the previous subsection, weprovide the addition of a normalising flow to the encoder-decoderpipeline to help model the prior distribution. In particular, we providethe substitution of the hyperprior network with a normalising flow.

The additional variable w decouples y from the entropy model, resultingin better reconstruction fidelity. Additionally, the encoder and decoderdownsample the input, acting as a preprocessing step that iscomplementary to the INN transformation that is unable to down- orup-sample. We highlight the necessity of a discrete normalising flow inthis pipeline, since the input ŷ is already quantised, and w is alsorequired to be discrete since it is directly fed to the arithmeticcoder. An example is shown in FIG. 63 .

7.2.3 Adding Hyperpriors to the Blocks of a Normalising Flow

In this subsection we describe a modification we make to normalisingflows using hyperprior networks. This modification has wideapplications, being virtually useful for any application of normalisingflows in image compression. The advantage they provide is a furtherreduction in bitstream size, due to the application of a hyperpriornetwork at each factor-out layer inside a normalising flow.

Normally, the factor-out layers of a normalising flow are connected to aparameterisation of the prior distribution modelled with a neuralnetwork. FIG. 64 shows an example in which partial output y offactor-out layer fed to a neural network, that is used to predict theparameters of the prior distribution that models the output.

In this integration, illustrated for example in FIG. 65 , we modify thisblock to include a hyperprior model. The figure shows an example inwhich output of factor-out layer is processed by a hyperprior and thenis passed to the parameterisation network.

Both the outputs of a factor-out layer (y and z) are fed to a hyperpriorautoencoder that outputs a feature map b. This feature map is thenconcatenated to y and fed to the parameter estimation model. Bycompressing y and z into w and sending this latent as side-information,we further improve the compression ability of the pipeline.

7.2.4 Using INN to Model p(X) and p(N) for Mutual Information

Mutual information (MI) between X and Y is defined as follows:

$\begin{matrix}{{I\left( {X;Y} \right)} = {{{\mathbb{E}}_{p({x,y})}\left\lbrack {\log\frac{p\left( {x{❘y}} \right)}{p(x)}} \right\rbrack} = {{\mathbb{E}}_{p({x,y})}\left\lbrack {\log\frac{p\left( {y{❘x}} \right)}{p(y)}} \right\rbrack}}} & (7.1)\end{matrix}$

We model p(y) and p(y|x) using INNs. This gives us approximations tothese values, which we can use to compute the I(X; Y). By being ableevaluate I(X; Y), we are able to maximize the mutual information betweenX and Y. A use case for this method is further described in our Mutualinformation section, Section 8.

FIG. 66 shows an example illustration of MI, where p(y) and p(y|x) iscomputed using INN transformations. Here [x, y] represents a depthconcatenation of the inputs.

7.2.5 Using INN Wherever we are Required to Model a Complex Density inOur Pipeline

In this subsection we introduce a form of meta-compression that sendsmodel weights along with image data. Sending model-specific informationenables a more flexible compression scheme, where the coding system istuned to the compressed image.

The neural weights of the network need to be compressed in order to besent as bitstream, in a similar way to how the latent space of theautoencoder is compressed. This requires two things:

-   -   1. Model the entropy of the weights;    -   2. Quantise the representation.

Generally, the distribution of the weights of a neural network can bevery complex. Hence, this is a suitable application for normalisingflows; not only that, we can quantise the weights readily with minimalloss of performance by taking advantage of Quantisation Aware Training(QAT), a standard feature of deep learning frameworks such as PyTorchand TensorFlow. After quantisation, we pass the weights of the neuralnetwork to an INN, that returns a processed representation of theweights following the prior distribution, and then we can encode thisrepresentation with an arithmetic encoder. The decoding processcomprises using an arithmetic decoder to retrieve the processed weights,and then undo the transformation by passing them to the inverse of thenormalising flow. An example illustration of such a pipeline is shown inFIG. 67 .

7.3 Concepts

Below we enumerate the concepts which relate to the present section.

-   -   1. The use of FlowGAN, that is an INN-based decoder with a        traditional neural encoder, for image and video compression;    -   2. The substitution of the encoder-decoder construct in media        compression with a continuous normalising flow, which reduces        the total size of the codec by reusing parameters;    -   3. A variation of concept 2 where a discrete flow is used        instead, resulting in a lossless compression pipeline;    -   4. Integrating the hyperprior network of a compression pipeline        with a normalising flow;    -   5. A modification to the architecture of normalising flows that        introduces hyperprior networks in each factor-out block;    -   6. INN for mutual information;    -   7. A meta-compression strategy where the decoder weights are        compressed with a normalising flow and sent along within the        bitstream.

8. Mutual Information for Efficient Learnt Image & Video Compression 8.1Introduction

In the field of learnt image and video compression, an aim is to producethe most efficient encoding of an image, meaning that there are noredundancies that are not required by the decoder to re-produce anaccurate compressed output. Another way this can be viewed is therequirement that the encoder must discard redundant information; this isimplicitly happening, however a way to further improve compressionefficiency is to explicitly model the inherent dependency between theinput and output, known as mutual information. Here mutual informationfor learnt compression is discussed and novel methods of trainingcompression pipelines with this metric are given.

Mutual information is a quite esoteric yet fundamental property that isuseful to represent relationships between random variables. It cannot bewell understood without a background in statistics and probabilitytheory. For two random variables the mutual information I(X; Y) may bemost intuitively expressed in terms of entropies H:

I(X; Y)=H(X)−H(X|Y)  (8.1)

This means that the mutual information between X and Y is equal to thereduction in the uncertainty (or entropy) of X (H(X)) reduced by howmuch we know about X if we are given Y (H(X|Y)). H(X|Y) is a measure ofwhat Y does not tell us about X, i.e. the amount of uncertainty thatremains about X after Y is known. The equation above can thus bereformulated in terms of text as follows:

The amount of uncertainty in X, minus the amount of uncertainty in Xthat remains after Y is known, which is equivalent to the amount ofuncertainty in X that is removed by knowing Y.

This is shown in FIG. 68 for example, in the form of a Venn diagram.Note that the area of the intersection of the two circles can beexpressed as H(X)−H(X|Y) which again represents the reduction in entropywhen Y is known.

Mutual information may also be expressed for probability densityfunctions as follows:

$\begin{matrix}{{I\left( {X;Y} \right)} = {{{\mathbb{E}}_{p({x,y})}\left\lbrack {\log\frac{p\left( {x{❘y}} \right)}{p(x)}} \right\rbrack} = {{\mathbb{E}}_{p({x,y})}\left\lbrack {\log\frac{p\left( {y{❘x}} \right)}{p(y)}} \right\rbrack}}} & (8.2)\end{matrix}$

This is equivalent to the KL divergence between a joint distributionp(x, y) and marginal distributions p(x), p(y). Mutual information can bemore succinctly expressed in terms of this F divergence:

I(X; Y)=D_(KL)(p(x, y)∥p(x)⊗p(y)) since the joint p(x, y) may beexpressed as a conditional p(x, y)=p(x|y)p(y). The intuitive meaning ofmutual information expressed with the KL divergence is that the largerthe divergence between the joint and the product of marginals, thestronger the dependence between X and Y.

Mutual information has found a wide range of meaningful applicationswithin the field of data science.

For our field of image compression, it should be clear that there is anotion of mutual information between an input image and itscorresponding compressed output from our compression pipeline. In fact,it turns out that for an autoencoder that is trained with an MSE loss,the network is learning to maximise (a lower bound on) the mutualinformation between the input and the latent representation Y, I(X; Y).This should make intuitive sense because by maximising I(X; Y) we arecompressing away information in Y that is not necessary to retrieve{circumflex over (X)} from Y, hence why a strong correlation between theinput X and Y is expected, which is what we observe for the latents (thecompressed bitstream) of our models.

8.2 Mutual Information Estimation

Notwithstanding the usefulness of mutual information for a wide range offields, estimation of mutual information for unknown probabilitydensities still remains intractable to compute. It's only tractable fordiscrete variables, or for a limited set of cases where knownprobability distributions may be applied.

Therefore there have been a number of efforts to provide estimators thatcan provide a tight lower or upper bound on the mutual information. Inthis section, the Barber & Agakov and InfoNCE bound is defined.

8.2.1 Unstructured Bounds Barer & Agakov

The Barber & Agakov upper bound is defined as follows:

$\begin{matrix}{{{I\left( {X;Y} \right)} \leq {{\mathbb{E}}_{p({x,y})}\left\lbrack {\log\frac{p\left( {y{❘x}} \right)}{p(y)}} \right\rbrack}} = {D_{KL}\left( {{p\left( {y{❘x}} \right)}{❘❘}{q(y)}} \right)}} & (8.3)\end{matrix}$

For the case of the lower bound on the mutual information, we replacethe intractable conditional distribution p(x|y) with a tractable problemover a variational distribution q(x|y):

$\begin{matrix}\begin{matrix}{{I\left( {X;Y} \right)} = {{{\mathbb{E}}_{p({x,y})}\left\lbrack {\log\frac{q\left( {x{❘y}} \right)}{p(x)}} \right\rbrack} + {{\mathbb{E}}_{p(y)}\left\lbrack {D_{KL}\left( {p\left( {x{❘y}} \right)} \middle| \middle| {q\left( {x{❘y}} \right)} \right.} \right\rbrack}}} \\{{\geq {{{{\mathbb{E}}_{p}\left( {x,y} \right)}\left\lbrack {\log q\left( {x{❘y}} \right)} \right\rbrack} + {{\mathbb{E}}_{p({x,y})}\log{p(x)}}}} = {{{{\mathbb{E}}_{p}\left( {x,y} \right)}\left\lbrack {\log q\left( {x{❘y}} \right)} \right\rbrack} + {h(X)}}}\end{matrix} & (8.4)\end{matrix}$

The Barber & Agarov lower bound is tight when q(x|y)=p(x|y).

Infonce

InfoNCE is a lower bound where a critic may be used to estimate thejoint and marginals.

$\begin{matrix}\begin{matrix}{{I_{NCE}\left( {X;Y} \right)} \geq {{\mathbb{E}}_{p^{K}({x,y})}\left\lbrack {\frac{1}{K}{\sum\limits_{i = 1}^{K}{\log\frac{p\left( {y_{i}{❘x_{i}}} \right)}{\frac{1}{K}{\sum_{j = 1}^{K}{p\left( {y_{i}{❘x_{j}}} \right)}}}}}} \right\rbrack}} \\{= {{\mathbb{E}}_{p^{K}({x,y})}\left\lbrack {\frac{1}{K}{\sum\limits_{i = 1}^{K}\left( {{\log{p\left( {y_{i}{❘x_{i}}} \right)}} - {\log\frac{1}{K}{\sum\limits_{j = 1}^{K}{p\left( {y_{i}{❘x_{j}}} \right)}}}} \right)}} \right\rbrack}} \\{= {{\mathbb{E}}_{p^{K}({x,y})}\left\lbrack {\frac{1}{K}{\sum\limits_{i = 1}^{K}\left( {{\log{p\left( {y_{i}{❘x_{i}}} \right)}} - {\log{\sum\limits_{j = 1}^{K}{p\left( {y_{i}{❘x_{j}}} \right)}}} + {\log K}} \right)}} \right\rbrack}}\end{matrix} & (8.5)\end{matrix}$

The role of the critic is to learn to predict p(y|x). The critic may beparameterized by a neural network.

8.3 an Innovation 8.3.1 Closed-Form Solution

In this section, a novel approach that seeks to maximize the mutualinformation between the reconstructed output of the compression pipelineand the input is explored. As explained in the introduction, maximizingthe mutual information is a method of producing a tight coupling betweentwo parameters.

In general, it is not clear how well mutual information estimators workfor high dimensional problems, such as image compression and the extentof the lower and upper bounds is hard to define. The estimators may bebiased or provide inaccurate estimates. A novel way around this issue isto treat the compression pipeline as a simple channel, the aim is toincrease the channel capacity—increasing channel capacity equates toincreasing the amount of information that can flow through the corruptedchannel. The highest channel capacity is achieved when the noise addedby our channel is zero. When the input x passes through the channel itis corrupted by noise n, as shown in Equation (8.6). Our aim is tomaximize the channel capacity by maximizing the mutual informationbetween the input x and the output z, essentially learning to removecorruptions introduced by the noisy channel.

{circumflex over (x)}=x+n  (8.6)

Modelling the input x and the noise n as zero-mean independent Gaussiantensors,

(0, σ²) it is possible to compute a closed-form solution of the mutualinformation I(x; {circumflex over (x)}) where x is the input and{circumflex over (x)} is the compressed media.

$\begin{matrix}{{I\left( {x;\overset{\hat{}}{x}} \right)} = {{{H(x)} - {H\left( {x{❘\overset{\hat{}}{x}}} \right)}} = {\frac{1}{2}\log\left( {1 + \frac{\sigma_{x}^{2}}{\sigma_{n}^{2}}} \right)}}} & (8.7)\end{matrix}$

The parameters σ_(x) and σ_(n) of Equation (8.7) are learnt by neuralnetworks. In terms of entropy modelling, the MVND entropy model may beused to model our source x and our noise n. However, in general, anytype of density estimation approach (such as Maximum likelihood orMaximum a posteriori) as well as any generative model (such as aPixelCNN, Normalizing flow, Variation auto encoders) can be used. Theaim of the training is to force our encoder-decoder compression pipelineto maximise the mutual information between x and {circumflex over (x)},which forces our output to share information with our ground truthimage. The training may be executed in multiple different ways.

The first method of training is to directly maximise mutual informationin a one-step training process, where the x and n are fed into theirrespective probability networks S and N. The mutual information over theentire pipeline is maximised jointly. This is shown in FIG. 70 forexample, where the black arrows represent information flow in theforward pass and dashed-lines show gradient flow in the backward pass.The loss is modified to include the mutual information estimation I(x;{circumflex over (x)}).

(x,{circumflex over (x)})=R(x)+λD(x,{circumflex over(x)})+αI(x;{circumflex over (x)})  (8.8)

The second approach is a bi-level or two-step process. Firstly, thenetwork S and N is trained using negative log-likelihood to learn auseful representation of σ_(n), and σ_(x), based on the closed-formsolution of the distribution selected. This part of the process is shownin FIG. 71 for example, where only N and S are trained. Secondly,estimates of σ_(n), and σ_(x) are then used to estimate the mutualinformation and train the compression network, however gradients onlyimpact the components within the area of the compression network;components are trained separately.

In general, for any function ƒ and g it holds that I(X; Y)≥I(g(X); ƒ(Y))where I(X; Y)=I(g(X); ƒ(Y)) if and only if ƒ and g are invertible andvolume-preserving, i.e. det(ƒ)=1 and det(g)=1. As such the noise nand/or the input x can be transformed by an arbitrary function as longas the constraints above apply, e.g. ƒ and g could be an invertibleneural networks (INN). The invertible transformation can be applied toeither X or Y or both. A particular analytical example of ƒ and g couldbe an orthogonal basis transform into another basis, or converted intoanother domain, such as the wavelet domain, to better model theprobability distributions.

In addition, the approach may also be applied on patches or segments ofimages. Also a multi-scale approach may be used, this is naturally thecase when the transformation above provides multiple different scales,such as the case given the wavelet transform, where mutual informationfor each scale is computed and then aggregated. This approach may alsobe further generalised to a multivariate distribution where the tensorto be modelled is split into blocks (in spatial and or channeldimensions) of variable sizes and modeled using a multivariate normaldistribution with a mean vector and co-variance matrix per block ofelements.

Finally the distribution used to model the source and noise is notlimited to a multi-variate Gaussian distribution, but may be extended toany continuous distribution such as Behrens-Fisher distribution, Cauchydistribution, Chernoff's distribution, Exponentially modified Gaussiandistribution, Fisher-Tippett, log-Weibull distribution, Fisher'sz-distribution, skewed generalized t distribution, generalized logisticdistribution, generalized normal distribution, geometric stabledistribution, Gumbel distribution, Holtsmark distribution, hyperbolicdistribution, hyperbolic secant distribution, Johnson SU distribution,Landau distribution, Laplace distribution, Levy skew alpha-stabledistribution or stable distribution, Linnik distribution, logisticdistribution, map-Airy distribution, etc,. This allows for more accuratemodelling of the source and noise while maintaining a close formedsolution.

8.3.2 Bounded Estimators for Compression

A novel method of performing compression using mutual information, thatdoes not involve a noisy channel, is to explicitly optimise the mutualinformation of the output and the input of the neural network such thatthis metric is maximised. The mutual information estimator used is notrestricted to the bounds presented in the earlier sections such asBarber & Agakov or InfoNCE, along with bounds not presented explicitly,such as TUBA, Nguyen-Wainwright-Jordan (NWJ), Jensen-Shannon (JS), TNCE,BA, MBU, Donsker-Varadhan (DV), IWHVI, SIVI, IWAE, etc., Moreover,neural networks (non-limiting examples include: INN, auto-encoders,conditional model) can also be applied to estimate probability estimatesp (x, y), p (x|y) for mutual information estimates. The loss of theneural network is therefore augmented in the following way:

(x,{circumflex over (x)})=R(x)+λD(x,{circumflex over(x)})+αI(x;{circumflex over (x)})  (8.9)

where x is the input, {circumflex over (x)} the output, R the estimatedrate, D compression distortion, I the estimated mutual information. λand α are scaling coefficients. A simplified generic example of thecompression network can be seen in FIG. 72 , which shows a simplifiedcompression pipeline.

8.3.3 Temporal Mutual Information

An extension of the mutual information, defined in Equation (8.2),appropriate for video content or temporally correlated media is tocondition the joint and the marginals based on N past data points, c.The conditioning may be applied using the compressed outputc_(i)={circumflex over (x)}_(i) or the ground truth input c_(i)=x_(i).Conditioning on the compressed media allows for a temporal reduction ofartifacts by enforcing logical and temporally consistent consecutiveframeS.

$\begin{matrix}{{I\left( {X;{Y{❘C}}} \right)} = {{\mathbb{E}}_{p({x_{i},{y_{i}{❘{c_{i - 1},\ldots,c_{i - N}}}}})}\left\lbrack {\log\frac{p\left( {x_{i},{y_{i}{❘{c_{i - 1},\ldots,c_{i - N}}}}} \right)}{{p\left( {x{❘{c_{i - 1},\ldots,c_{i - N}}}} \right)}{p\left( {y{❘{c_{i - 1},\ldots,c_{i - N}}}} \right)}}} \right\rbrack}} & (8.1)\end{matrix}$

During variational approximations, the conditional or marginal may beparameterised as a neural network; the conditional approximation wouldbe given as input the previous N samples, in addition to the current ithsample.

8.3.4 Optimising for Entropy

In the previous sections, mutual information optimisations was performedfor the input and output of the compressed media, by computing I(x;{circumflex over (x)}), however, this can be extended to optimise forbit-rate R. Maximising mutual information of the latent parameter y anda particular distribution

, as seen in Equation (8.11), can be used to optimise for rate.

$\begin{matrix}{{\underset{y}{\arg\max}{I\left( {y;n} \right)}},{n \sim {\mathcal{P}( \cdot )}}} & (8.11)\end{matrix}$

This is because rate is computed using Equation (8.12), where q_(y) isthe tractable probability distribution estimate of p_(y) by an entropymodel.

R=H(p _(y) ,q _(y))=E _(y˜p) _(y) [−log₂(q _(y)(y))]  (8.12)

When I(y; n) is maximised, p_(y)≈

, such that the unknown distribution p_(y) can be modelled as a noisyknown distribution

, this provides a more efficient entropy computation. The mutualinformation of I(y; n), as shown in Equation (8.13), requires that p_(y)and

be dependent. In simplified form

$\begin{matrix}{{{\log\left( \frac{p_{p_{y},\mathcal{P}}\left( {y,n} \right)}{{p_{p_{y}}(y)}{p_{\mathcal{P}}(n)}} \right)} = {{\log\left( {p_{p_{y},\mathcal{P}}\left( {y,n} \right)} \right)} - {\log\left( {{p_{p_{y}}(y)}{p_{\mathcal{P}}(n)}} \right)}}};} & (8.13)\end{matrix}$ y ∼ p_(y), n ∼ 𝒫

which is maximised if the joint probability is large and the marginalprobability is small, i.e. strong dependence.

For the case where

has a known closed-form solution, this can be optimised for directlyusing negative log-likelihood, as shown in for example FIG. 73 . Inaddition, since the hyper-prior models provide estimates for μ and σthese values are used to guide the optimisation. For this case, the rateloss R of y has to be computed with a cross entropy term, as shownabove, such that μ and σ learn useful parameters. If

=N(0, 1), the mutual information can be computed using Equation (8.7).

In the example of FIG. 74 , the bit-rate is only controlled by themutual information estimate L, where L is a particular mutualinformation estimate, such as InfoNCE given by Equation (8.5). The lossto train the critic is given by

=−L.

8.3.5 Concepts

-   -   1. Maximising mutual information of the input and output by        modelling the difference {circumflex over (x)}−x as noise    -   2. Maximising mutual information of the input and output of the        compression pipeline by explicitly modelling the mutual        information using a structured or unstructured bound    -   3. A temporal extension of mutual information that conditions        the mutual information of the current input based on N past        inputs.    -   4. Maximising mutual information of the latent parameter y and a        particular distribution        is a method of optimising for rate in the learnt compression        pipeline

9. From AAE to WasserMatch: Alternative Approaches for Entropy Modellingin Image and Video Compression 9.1 Introduction

In learnt image and video compression, the latent space is normallyconditioned to follow a certain distribution using maximum likelihoodestimation (MLE). We describe alternative approaches to learntcompression that integrate and exploit other methods of enforcingspecific densities on latent spaces. This allows us to circumvent somelimitations of MLE and obtain greater flexibility in the classes ofdistributions that can be modelled.

9.1.1 Maximum Likelihood Estimation of Entropy Model in LearntCompression

Learnt image and video compression mainly consists in three components:an encoder neural network, an entropy model, and a decoder neuralnetwork (the encoder and decoder networks together are referred to as anauto-encoder). The encoder network processes the image or video into arepresentation called a latent space, and the decoder network appliesthe reverse transformation. The encoder network applies a firstpre-processing step before the entropy model is applied.

The entropy model is represented as a uni- or multi-variate probabilitydistribution p_(m) (y), normally assumed to have a parametric form (forexample, a standard Normal distribution, or a Laplacian distribution,etc). The parameters of the entropy model are usually fitted to thetraining data (using methods like maximum likelihood), although this isnot a requirement—it only improves the compression efficiency of thepipeline. On the other hand, the actual marginal distribution of thedata p(y) is not known in advance.

With an entropy model in place, we can further compress the latent spaceusing an entropy code such as Huffman coding or arithmetic coding: theamount of bits B contained in this code (which is the bitstream that isused as the final compressed representation) can be calculated usingShannon's cross-entropy.

B=Σp(y)log₂(P _(m)(y))  (9.1)

This quantity is minimised when p(y) and p_(m)(y) are the sameprobability distribution, i.e. when the distribution in the entropymodel matches the real distribution of the latent space.

Fortunately, we can directly train our models towards this objective, infact the usual form of the loss function of a learnt compression modelis

L=D(x,{circumflex over (x)})+λB(y)  (9.2)

Where D is a distortion loss between the original image and thecompressed+decompressed image (less distortion equals better fidelity.

An important concept to keep in mind is that Shannon entropy is onlyvalid on discrete sets of symbols. This means that, in order to applyarithmetic coding on the numerical values inside the latent space, weneed to quantise these values.

Quantisation is a big problem in learnt image and video compression,because the quantisation operation has no gradient, and our networks aretrained using gradient descent, so it requires all operations inside thepipeline to be differentiable. In practice, a differentiable substituteis used instead of quantisation during training, for example theaddition of noise, or the Straight-Through Estimator (STE); however,this is just an approximation of the real operation.

What if we could bypass the quantisation operation?

Here we address this question.

9.1.2 Generative Adversarial Networks (GANs)

GANs are often used when it is not clear what form the loss functionshould have. This is especially applicable to generation tasks, wherethe loss needs to define what a realistic-looking image looks like. Forinstance, if a model is trained to generate human faces, the loss shouldcontain information such as what is a realistic-looking nose, arealistic location for eyes and mouth, a realistic skin color, etc. Sucha loss is impossible to craft manually, hence we substitute the lossfunction with a second neural network referred to as a Discriminator.

The discriminator is trained as a classifier that needs to differentiatebetween the images generated by the generator, and the images in thetraining dataset. The generator network has the opposite objective: togenerate images that will be classified as real, despite being generatedby the network. In artificial intelligence, this is referred to as azero-sum minimax game: zero-sum because the loss of the generator isdirectly opposite to the loss of the discriminator; and minimax becausethe objective of the networks is to minimise the loss of each network inthe worst possible case, that is when the loss of the other network isat a minimum.

9.1.3 Adversarial Auto-Encoders (AAEs)

As described in a previous subsection, learnt compression pipelines makeuse of an entropy model to further compress data. This is done withmaximum likelihood estimation on the latent space, under the priorassumption that the probabilities of its values follow a certaindistribution. Adversarial training can be an effective alternative tomaximum likelihood: indeed, AAEs make use of GAN-style training toenforce a specific distribution on their latent space.

The task of the discriminator network is to differentiate between thelatent space and samples from a known prior distribution. Conversely,the task of the generator network (in AAEs, the generator is theencoder) is to generate latent spaces that are indistinguishable fromthe prior distribution. FIG. 75 shows an example illustration of atypical AAE setup.

AAEs are autoencoders that use GAN-style training.

The biggest advantage of AAEs as opposed to autoencoders trained withMLE is that AAE training is sample-based, while MLE requires parametricdistributions with analytical form. Examples of parametric distributionsinclude normal, laplacian, beta distributions, etc. This puts a strictlimit on what class of distribution the latent space is allowed tofollow, because many distributions have no analytical form but can beuseful priors (for example, categorical distributions where the valuescan only assume one of a finite set of values).

9.1.4 Analytical Vs Sample-Based Distributions

Analytical distributions have a density that can be represented as aformula. For example, a Normal distribution has a probability densityfunction defined as

$\begin{matrix}{{d(x)} = {\frac{1}{\sigma\sqrt{2\pi}}\exp\frac{\left( {x - \mu} \right)^{2}}{\sigma}}} & (9.3)\end{matrix}$

This means that the density can be simply calculated at any point in thedistribution's support (the set of numbers it is defined on). Having ananalytical form also enables a range of techniques such asdifferentiable sampling in the form of the reparametrisation approach(we remind the reader that operations used in a learnt pipeline need tobe differentiable in order to work).

On the other hand, an example of a non-analytical distributions is acategorical distribution where the only information we have is a fewsamples as listed below:

l={0,0,3,1,0,2,3,0,2}  (9.4)

We cannot backpropagate through such a distribution, hence it is moreproblematic to include in a learnt compression pipeline.

9.1.5 Measures of Distance Between Distributions

It is useful to understand how the difference between one probabilitydistribution and the other can be calculated, as there are innumerablemethods for estimating distance between distributions.

KL Divergence: a widely used method in machine learning is theKullback-Leibler (KL) divergence, sometimes referred to as relativeentropy. The KL divergence between distributions P and Q is defined as

$\begin{matrix}{{D_{KL}\left( {P{❘{❘Q}}} \right)} = {\int_{- \infty}^{+ \infty}{{p(x)}\log\left( \frac{q(x)}{p(x)} \right)dx}}} & (9.5)\end{matrix}$

Where p(x) and q(x) are the densities of the distributions at point x.

This distance has a limitation. As shown in (9.5), the density p(x) atall points needs to be known, and this is only the case when thedistribution has an analytical form. So, the KL divergence can't be usedfor all distributions.

Moment Matching: a simpler way of comparing distributions is simply tocalculate their moments and compare the corresponding moment of onedistribution against the moment of the other. Moments of a distributionsare numbers that describe the shape of its density, for example thefirst moment of a distribution is its mean, the second moment is itsvariance, the third moment is the skewness, etc. In order to quicklycalculate a measure of difference between two distributions, we cancalculate the difference between the mean of one and the mean of theother, then the difference between the variance of one and the other,etc. This has the advantage of being completely sample-based, that is,we don't need to know the analytical form of the distribution, we justneed to be able to draw samples from it.

MMD: maximum mean discrepancy is another method that does not requirethe distributions to have an analytical form. It is weakly related tomoment matching, and could be considered a generalisation of it.

Let us define a kernel h that maps from the set

to the set

. Maximum mean discrepancy is then defined as

MMD(P, Q)=∥

_(x˜p) [h(X)]−

_(y˜Q) [h(Y)]∥

  (9.6)

That is, the norm of the difference between the expected value of thekernel embedding of the first distribution and the second. As a simpleexample, if we pick h to be the identity function, MMD reduces to firstmoment matching (i.e. the embeddings collapse into the mean of thedistributions).

Optimal Transport: this family of methods stems from the field ofoperations research. The distance between distributions is formulated interms of finding the most efficient transportation plan that movesprobability mass from one distribution to the other.

The most well-known measures of distance in optimal transport theory areWasserstein distances.

Mathematically, if we define a transportation plan between distributionsas γ from the set containing all transport plans Γ. and a cost oftransport c, W-distances are defined as below:

$\begin{matrix}{{W\left( {P,Q} \right)} = {\underset{\gamma \in {\Gamma({P,Q})}}{\inf}{\int_{{\mathbb{R}}^{d} \times {\mathbb{R}}^{d}}{{c\left( {x,y} \right)}d{\gamma\left( {x,y} \right)}}}}} & (9.7)\end{matrix}$

That is, the minimum-cost transportation plan to move all the mass of Pinto Q. The transportation cost is usually the L1 norm, in which casethe distance is the Wasserstein-1 distance.

Just as MMD, Wasserstein metrics are also purely sample-based, i.e. theycan be used with any probability distribution regardless of whether theyhave an analytical form. However, W-distances are non-trivial to computebecause they require finding the minimum-cost transportation plan. Thisis an optimisation problem, which is non-differentiable and can beextremely computationally intensive when the distributions are veryhigh-dimensional.

Sinkhorn Divergences

Sinkhorn divergences can be considered a generalisation of both MMD andWasserstein metrics. Mathematically they are formulated as below:

$\begin{matrix}{{S\left( {P,Q} \right)} = {{W_{\epsilon}\left( {P,Q} \right)} - {\frac{1}{2}{W_{\epsilon}\left( {P,P} \right)}} - {\frac{1}{2}{W_{\epsilon}\left( {Q,Q} \right)}}}} & (9.8)\end{matrix}$

Where W_(∈) is a regularised form of Wasserstein distances defined asbelow:

$\begin{matrix}{{W_{\epsilon}\left( {P,Q} \right)} = {{\inf\limits_{\gamma \in {\Gamma({P,Q})}}{\int_{{\mathbb{R}}^{d} \times {\mathbb{R}}^{d}}{{c\left( {x,y} \right)}d{\gamma\left( {x,y} \right)}}}} + {\epsilon{{KL}\left( {\gamma{❘{P \times Q}}} \right)}}}} & (9.9)\end{matrix}$

If we compare against Equation (9.7) we can see that an additional KLdivergence term has been added. This has the effect of mitigating themain problem with Wasserstein distances (their non-smoothness andsubsequent computational expensiveness).

9.2 Innovation 9.2.1 Learning Latent Distribution Through DivergenceMinimisation

We present three general frameworks where the latent space of anauto-encoder is forced to follow a particular distribution by a jointtraining process.

-   -   Framework 1 comprises a one-step training pipeline, usable with        analytical prior distributions;    -   Framework 2 comprises a two-step process with adversarial        training, used with sample-based distributions;    -   Framework 3 comprises a two-step process without adversarial        training, also suitable for sample-based distributions.

The algorithm of the first framework is detailed below:

Algorithm 9.1 Training process for auto-encoder trained withframework 1. The backpropagate( ) method is assumed to retrievegradients of the loss with respect to the network weights.Backpropagation optimiser is assumed to have a step( ) method thatupdates the weights of the neural network.   Inputs: Encoder Network:f_(θ) Decoder Network: g_(ϕ) Reconstruction Loss: L_(R) Entropy Loss:L_(B) Input tensor: x ∈

^(H×W×C) Training step: y ← f_(θ)(x) {circumflex over (x)} ← g_(ϕ)(y) L← L_(R)(x, {circumflex over (x)}) + λL_(B)(y)$\left. {\frac{dL}{d\theta},\frac{dL}{d\phi}}\leftarrow{{backpropagate}(L)} \right.$$\left. \theta\leftarrow{{{optimizer} \cdot {step}}\left( {\theta,\frac{dL}{d\theta}} \right)} \right.$$\left. \phi\leftarrow{{optimizer} \cdot {{step}\left( {\phi,\frac{dL}{d\phi}} \right)}} \right.$Repeat Training step for i iterations.

This framework is equivalent to the standard learnt compressionpipeline, where the prior distribution is embedded inside the entropyloss. The difference in our approach is the choice of L_(B): while thestandard pipeline uses KL divergence, our choice is more free in that wealso use moment matching as one of the divergence measures, which hasnot been done previously.

The algorithm for the second framework is below:

Algorithm 9.2 Training process for auto-encoder trained with framework2. We define a prior distribution P, then in training step 2 we sample pfrom it and feed both the sample and the latent space to thediscriminator, which outputs “realness” scores for each. Theencoder/generator is then trained to output latent spaces that look more“real”, akin to the samples from the prior distribution.   Inputs:Encoder/Generator Network: f_(θ) Decoder Network: g_(ϕ) DiscriminatorNetwork: h_(ψ) Reconstruction Loss: L_(R) Generator Loss: L_(g)Discriminator Loss: L_(d) Input tensor: x ∈

^(H×W×C) Prior distribution: P Training step 1: y ← f_(θ)(x) {circumflexover (x)} ← g_(ϕ)(y) L ← L_(R)(x, {circumflex over (x)})$\left. {\frac{dL}{d\theta},\frac{dL}{d\phi}}\leftarrow{{backpropagate}(L)} \right.$$\left. \theta\leftarrow{{{optimizer} \cdot {step}}\left( {\theta,\frac{dL}{d\theta}} \right)} \right.$$\left. \phi\leftarrow{{{optimizer} \cdot {step}}\left( {\phi,\frac{dL}{d\phi}} \right)} \right.$Training step 2 (adversarial): p~P s_(r) ← h_(ψ)(p) s_(f) ← hψ(y) L_(d)← λL_(d)(s_(r), s_(f)) L_(g) ← λL_(g)(s_(r), s_(f))$\left. \frac{dL}{d\theta}\leftarrow{{backpropagate}\left( L_{g} \right)} \right.$$\left. \frac{dL}{d\psi}\leftarrow{{backpropagate}\left( L_{d} \right)} \right.$$\left. \theta\leftarrow{{optimizer} \cdot {{step}{}\left( \frac{dL}{d\theta} \right)}} \right.$$\left. \psi\leftarrow{{{optimizer} \cdot {step}}\left( \frac{dL}{d\psi} \right)} \right.$Repeat Training steps 1 and 2 for i iterations.

The above algorithm describe the adversarial auto-encoder setup that weuse for image compression. This allows us to force the latent to followa sample-based distribution that has no analytical form.

In addition, we use a variety of adversarial setups for the generatorand discriminator. The first category is class probability estimation,which includes all losses in FIG. 76 .

The second category is direct divergence minimisation usingf-divergences such as:

-   -   Kullbach-Leibler divergence;    -   Jensen-Shannon divergence;    -   Inverse KL divergence.

The third category is the direct minimisation of a Bregman divergence,and the fourth category is moment-matching.

The algorithm for the third framework is below:

Algorithm 9.3 Training process for auto-encoder trained with framework3. We define a prior distribution P, then in training step 2 we sample pfrom itand compute our divergence measure between it and the latent y.  Inputs: Encoder Network: f_(θ) Decoder Network: g_(ϕ) ReconstructionLoss: L_(R) Entropy Loss (divergence): L_(B) Input tensor: x ∈

^(H×W×C) Prior distribution: P Training step 1: y ← f_(θ)(x) {circumflexover (x)} ← g_(ϕ)(y) L ← L_(R)(x, {circumflex over (x)})$\frac{dL}{d\theta},\left. \frac{dL}{d\phi}\leftarrow{{backpropagate}(L)} \right.$$\left. \theta\leftarrow{{{optimizer} \cdot {step}}\left( {\theta,\frac{dL}{d\theta}} \right)} \right.$$\left. \phi\leftarrow{{optimizer} \cdot {{step}\left( {\phi,\frac{dL}{d\phi}} \right)}} \right.$Training step 2: p~P L ← λL_(B)(y, p)$\left. \frac{dL}{d\theta}\leftarrow{{backpropagate}(L)} \right.$$\left. \theta\leftarrow{{{optimizer} \cdot {step}}\left( \frac{dL}{d\theta} \right)} \right.$Repeat Training steps 1 and 2 for i iterations.

This framework is easier to train than framework 2 because there is noadversarial training. Additionally, it is more flexible than framework1, in that the entropy loss calculation depends purely on sampling fromthe prior distribution and comparing the sample against the latent spaceusing one of the following measures:

-   -   Mean Maximum Discrepancy    -   Optimal Transport (Wasserstein Distances)    -   Sinkhorn Divergences

Mean Maximum Discrepancy is differentiable, and so are SinkhornDivergences. But pure Optimal Transport measures are not. A contributionof ours is a simplification of Wasserstein distances that exploits thefact that W-distances are differentiable in the special case where thedistributions are univariate.

In the 1-dimensional case, Wasserstein collapses to the followingdefinition:

$\begin{matrix}{{W_{1D}\left( {P,Q} \right)} = {\frac{1}{M}{\sum\limits_{m = 1}^{M}{c\left( {p_{i\lbrack m\rbrack},y_{j\lbrack m\rbrack}} \right)}}}} & (9.1)\end{matrix}$

Where M is the number of elements in p and y, which are the sample fromthe prior distribution and the latent space respectively. Indices i[m]and j[m] are the indices of the sorted values of the tensors inascending order.

As we can see in the equation above, we no longer need to find theinfimum of the transport plans, so the optimisation problem is done awaywith completely. An illustration of what this divergence measures isshown in FIG. 77 .

With univariate distributions, calculating the Wasserstein-1 distance isequivalent to calculating the L1 norm between the sample and the latent,once their elements have been sorted by value. This results in a simplecode implementation, defined below:

Algorithm 9.4 Pseudocode of Wasserstein distance with univariatedistributions. Note, the sampled tensor and latent space tensor areflattened before processing. Inputs: Sample from prior distribution: p ∈

 ^(N) Latent space: y ∈

 ^(N) Define: L1(p, y) : ||{circumflex over (p)} − ŷ||₁ Calculate W-1distance:   {circumflex over (p)} = sorted(p) ŷ = sorted(y) W =L1({circumflex over (p)}, ŷ) return W

Naturally, the algorithm outlined in Algorithm 9.4 is not limited to usethe Wasserstein-1 distance: for example, if calculating theWasserstein-2 distance is required, all that is needed is to substitutethe L1 norm with an L2 norm.

A limitation with Algorithm 9.4 is that the input tensors are flattenedbefore sorting, thus it only supports univariate distributions, whichhave a much smaller representational power compared to multivariatedistributions. However, we circumvent this limitation by defining aseparate prior distribution for each channel or pixel in the latentspace, then sampling from each of these distributions (see FIG. 78 forexample).

Note that in FIG. 78 we sample all channels of a pixel from the sameprobability distribution; in practice we can also sample each channelfrom a separate distribution.

After sampling the target tensor, we calculate the Wasserstein distanceseparately for each pair of corresponding pixels in the latent space andsampled tensor, as below:

W _(u,v) =W _(1D)(S _(u,v) ,Y _(u,v))  (9.11)

And finally we aggregate all these individual Wasserstein distances byaveraging:

$\begin{matrix}{{W\left( {s,y} \right)} = {\frac{1}{MN}{\sum\limits_{u}^{M}{\sum\limits_{v}^{N}W_{u,v}}}}} & (9.12)\end{matrix}$

Note that when using W-1 distance channel- or pixel-wise, a large batchof images is required to obtain a large enough sample size.

9.2.2 Learning a Discrete Distribution with and without ExplicitQuantisation

Using sample-based entropy losses, such as what is used in framework 3,unlocks a new capability with our models, that is, enforcing a discretedistribution on the latent space without explicitly using thequantisation operation.

The training pipeline is completely unchanged from the one associatedwith framework 3, the only difference being that the prior distributionis now a discrete distribution instead of being continuous.

The absence of an explicit quantisation operation means that, duringtraining, the encoder will learn to generate latent spaces that containa(n approximately) discrete set of values. This is a great advantage, asit allows us to apply arithmetic coding on the latent space without itbeing passed through an operation with ill-defined gradients, such asquantisation is. Additionally, the framework can just as easily be usedwith an explicit quantisation built-in, where the latent space istrained against a discrete prior after being quantised. The differencebetween these two schemes is shown in FIGS. 79 and 80 .

9.2.3 Incorporating Side-Information by Predicting Probability Values ofa Categorical Distribution

So far, all the entropy models and strategies we have described arefixed at inference time, that is, when we compress any image the entropydistribution will be the same.

An improvement over this fixed entropy approach is to incorporate someside-information in the bitstream: this side-information containsinstructions on how to modify the entropy model for that particularimage, so that a greater amount of flexibility is allowed, which resultsin a higher compression performance.

Traditionally, such side-information has been created with hyperpriornetworks in learnt compression. A hyperprior network predicts themoments of the prior distribution: for instance, it could predict themean and variance of a normal distribution. This distribution is thenused to entropy code and decode the latent space.

We provide a similar pipeline for framework 3, illustrated in FIG. 81 byway of example:

Additionally, we provide a different strategy. This strategy is based onthe premise that for a fixed bitrate there are infinite probabilitydistributions, and thus the objective of our model is to find thedistribution that results in the highest reconstruction fidelity for agiven bitrate.

This is achieved by setting the prior distribution to be categorical,i.e. a discrete distribution with a finite set as its support (e.g. thevalues {0, 1, 2, 3}) and arbitrary probabilities for each value (e.g.{0.1, 0.2, 0.5, 0.2}. These probability values can be either learnt overthe training dataset, or predicted by a hyperprior model. This method isillustrated in FIG. 82 , by way of example.

Note, in order for gradients to flow back from Wasserstein to theparameters of the hyperprior network (so that the hyperprior can learnto predict good probability values), it is required to backpropagatethrough the Sample operation, but sampling from a categoricaldistribution is normally not a differentiable operation with respect tothe probability values.

We present a differentiable approximation of this operation. TheProbability Mass Function (PMF) of a categorical distribution may lookas in FIG. 83 :

First, we sample from a standard uniform distribution; secondly, we mapeach sampled value to categorical space with a piecewise linearfunction, where the width of each segment is dictated by the probabilityvalue of the categorical distribution. In order to discretise thevalues, we finally apply quantisation with a Straight-through Estimatorto retain gradients for backpropagation. For an illustration of thisprocess, see the example of FIG. 84 .

There is one more hurdle to overcome: since the probability values arepredicted by the model, we need a transformation that maps R to thesolution space of the under-determined system of equations below:

Σ_(i) ^(N) p _(i)=1

Σ_(i) ^(N) −p _(i) log₂(p _(i))=B  (9.13)

Where p_(i) is the probability of each value in the distribution and Bis a target bitrate that is known in advance and can be specified by theuser.

We provide a transformation that contains an iterative method. Thetransformation algorithm is as below:

Algorithm 9.5 Iterative algorithm that produces a vector p thatsatisfies both conditions in Equation (9.13). The algorithm makes use ofa backpropagate( ) method to calculate gradients and an optimizer toupdate parameters.   Inputs: Input tensor: x ∈ 

^(N) Target Bitrate: B Step: p ← Softmax(x) H ← Σ_(i) ^(N) −p_(i)log₂(p_(i)) L ← ∥H − B∥₁$\left. \frac{dL}{dx}\leftarrow{{backpropagate}(L)} \right.$$\left. x\leftarrow{{{optimizer} \cdot {step}}\left( {x,\frac{dL}{dx}} \right)} \right.$Repeat Step until convergence.

9.2.4 Incorporating a Normalising Flow

The final innovation we describe is an additional step on top offramework 3. The step comprises in taking the latent space of theauto-encoder and passing it to a normalising flow. The normalising flowis perfectly invertible, which means that if we take its output and passit back to the flow, we will obtain the original input without anydistortion.

We exploit this property by inserting the normalising flow between thelatent and the entropy loss, i.e. we take the latent y, pass it to ournormalising flow, obtain an alternative representation w and calculateour divergence measures on w instead of y. The pipeline is illustratedin FIG. 85 , by way of example.

The normalising flow becomes part of the compression pipeline, so weonly need to send w as bitstream and then reconstruct y from it atdecoding time. The training process of such a system is described inAlgorithm 9.6.

Algorithm 9.6 Training algorithm of compression pipeline from FIG. 85for example. Inputs: Encoder/Generator Network: f_(θ) Decoder Network:g_(ϕ) Discriminator Network: h_(ψ) INN: j_(ω) Reconstruction Loss: L_(R)Generator Loss: L_(g) Discriminator Loss: L_(d) INN MLE loss: L_(INN)Input tensor: x ∈ 

^(H×W×C) Prior distribution: P INN training scale: λ Training step 1: y← f_(θ)(x) w ← j_(ω)(y) {circumflex over (x)} ← g_(ϕ)(y) L ← L_(R)(x,{circumflex over (x)}) + λL_(INN)(w)$\left. {\frac{dL}{d\theta},\frac{dL}{d\phi},\frac{dL}{d\omega}}\leftarrow{{backpropagate}(L)} \right.$$\left. \theta\leftarrow{{{optimizer} \cdot {step}}\left( {\theta,\frac{dL}{d\theta}} \right)} \right.$$\left. \phi\leftarrow{{{optimizer} \cdot {step}}\left( {\phi,\frac{dL}{d\phi}} \right)} \right.$$\left. \omega\leftarrow{{optimizer} \cdot {{step}\left( {\omega,\frac{dL}{d\omega}} \right)}} \right.$Training step 2 (adversarial): p~P s_(r) ← h_(ψ)(p) s_(f) ← hψ(w) L_(d)← λL_(d)(s_(r), s_(f)) L_(g) ← λL_(g)(s_(r), s_(f))$\left. \frac{dL}{d\theta}\leftarrow{{backpropagate}\left( L_{g} \right)} \right.$$\left. \frac{dL}{d\psi}\leftarrow{{backpropagate}\left( L_{d} \right)} \right.$$\left. \theta\leftarrow{{{optimizer} \cdot {step}}\left( \frac{dL}{d\theta} \right)} \right.$$\left. \psi\leftarrow{{{optimizer} \cdot {step}}\left( \frac{dL}{d\psi} \right)} \right.$Repeat Training steps 1 and 2 for i iterations. If the scale λis zero,then the INN is trained purely with adversarial or Wasserstein training.If the scale is greater than zero, the training is joint adversarial andMLE.

Using a normalising flow to further process the latent space allows y toretain spatial correlation information, while making w more similar tothe prior distribution.

9.3 Concepts

Below we enumerate the concepts we described.

First, we identify three image and video compression pipelines.

-   -   1. The first one comprises a one-step joint training process        where the model is trained to minimise reconstruction distortion        and divergence between its latent space and a prior distribution        with analytical form.    -   2. The second framework comprises in a two-stage adversarial        training process, where the first stage comprises distortion        minimisation, and the second stage comprises entropy        minimisation in an adversarial manner. This allows distributions        without an analytical form to be used as prior.    -   3. The third framework is a two-stage process without        adversarial training. Instead of relying on a GAN setup, this        framework makes use of alternative sample-based divergence        measures such as MMD or Wasserstein distances.

Furthermore, we identify two novel compression pipelines.

-   -   4. A pipeline that incorporates side-information in the form of        moments (e.g. mean and variance) of the prior distribution,        predicted at encoding time.    -   5. A pipeline that incorporates side-information in the form of        probability values of a categorical prior distribution.

Finally, we identify two methods associated with concept 5.

-   -   6. A method for sampling from a categorical distribution in a        differentiable manner, by exploiting a piecewise linear mapping        on a uniformly distributed sample.    -   7. A transformation that maps arbitrary numbers predicted by a        neural network to the solution space of a system of equations,        so that the resulting numbers (probabilities) sum to one and        their entropy is a predetermined value.    -   8. The addition of an INN to the general framework to decouple        the latent space from the entropy model; this addition is valid        for both adversarially-trained autoencoders, and non-adversarial        pipelines.

10. Asymmetric Routing Networks for Neural Network Inference Speedup10.1 Introduction

Multi-task learning (MTL) with neural networks leverages commonalitiesin tasks to improve performance, but often suffers from taskinterference which reduces the benefits of transfer. To address thisissue we introduce the routing network paradigm, a novel neural networkand training algorithm. A routing network is a kind of self-organizingneural network comprising two components: a router and a set of one ormore function blocks. A function block may be any neural network—forexample a fully-connected or a convolutional layer. Given an input therouter makes a routing decision, choosing a function block to apply andpassing the output back to the router recursively, terminating when afixed recursion depth is reached. In this way the routing networkdynamically composes different function blocks for each input.

The introduction will cover the problem setting, the intuition behindthe solution, and an overview of how it is implemented.

10.1.1 the Problem Setting

A general challenge of the neural networks is that they arecomputationally heavy and have a significant memory footprint.Therefore, they can not yet run in real-time on most consumer devices(edge devices). This execution-complexity remains a considerablechallenge for the AI-based Compression pipeline, amplified by its strictreal-time requirements of 33 ms per decoder pass. Note that we used theword “decoder” and not the “entire algorithm” in the last sentence.Compression can use asymmetric approaches in which encoding the datadoes not come with “too strict” time requirements, but decoding the datacomes with harsh real-time restrictions. For instance, a 30 fps movierequires decoding times below 33 ms; a 60 fps movie requires decodingtimes below 16.3 ms.

Why are neural networks so slow to execute? There are two primaryfactors. First, neural networks require a tremendous amount ofcomputations, often in the billions, for an inference pass. They havemany (floating-point) operations (FLOPs) to execute; and arebottlenecked to the following fps:

$\begin{matrix}{{\max\left( {{algorithm} - {fps}} \right)} = \frac{{AVAILABLE}{FLOPS}}{{FLOPS}{PER}{INFERENCE}{PASS}}} & (10.1)\end{matrix}$

Second, neural networks have a tremendous memory footprint and movement.This means that before data can be used for calculations, it has to bemoved from one memory location to another. There is a limit to how muchmemory can be transferred per second, given by the memory-speed. Thus, aneural network fps is either constrained by its FLOP-limit or by itsmemory-limit (more often the case). The roofline model in FIG. 86visualises this behaviour.

It is necessary to understand that the runtime issue will not disappearany time soon. While neural engines, specific chips designed for neuralnetwork execution-only, are becoming more abundant, they only increasethe compute power. With more computing power, we can execute more(floating-point) operations (FLOPs) per second. However, the memoryfootprint issue remains, and there are not so many advances made on thistopic recently.

10.1.2 the Solution—Intuition

It is well known in the Deep Learning community that we can build vastlydifferent looking neural networks/architectures for a similarperformance. However, all this achieves is to trade off memory footprintversus memory movement versus flops. For instance, for the sameperformance, we can build:

-   -   a huge-FLOP model with little memory movement and memory        footprint→Use small kernels, little downsampling, low width,        high depth, a limited number of skip connections.    -   a high memory footprint model with low FLOPs and little memory        movement→Use large kernels, a lot of downsampling, high width,        abitrary depth, a limited number of skip connections.    -   a large memory movement model with low FLOPs and little memory        footprint→Use small kernels, little downsampling, low width,        high depth, a lot of skip connections.

Neural Network Architecture Search (NAS) helps to find a good trade-offbetween these three properties. However, this does not help with runtimebecause we must reduce FLOPS, memory footprint and memory movement for ameaningful runtime reduction. So, what else can we do to get a runtimereduction? The answer is to use fewer operations of all types but usethese operations more efficiently.

An example: Let's assume we train a neural network with a generativeloss for compression. If we have a dataset that comprises faces andcars, we could train one generalised network for compression; or wecould train two networks, one for the faces and one for cars. If wetrain two networks, we will see that our compression performance will bebetter than if we train only one network. Why is this the case? Ithappens because the available network operations specialise given theirinput data and become more efficient. Essentially, we re-formulated theproblem of compressing “all images/videos” into the multi-class datasetproblem of compressing numerous different classes of images/videos. Ifwe go to the limit and train one network per class, we will get themaximum efficiency per operation in our network for its given class.

10.1.3 the Solution—Routing Networks

The specialisation described above does not help us reduce runtime dueto the necessity of having N different neural networks for N dataclasses. If we have more neural networks, the memory footprint increasesbecause of the network parameterisations/weights.

The real solution is to realise that even if we have multiple networksfor multiple data classes, there is a high likelihood that “most”operations will be the same—only a few operations will actuallyspecialise. Thus, instead of re-formulating the problem as a multi-classdataset problem, we can re-formulate the issue as a multi-task learning(MLT) problem. Therefore, our new tasks become to find one algorithmthat can learn multiple tasks instead of multiple algorithms formultiple tasks. FIG. 87 shows an example of the differences betweenthese interpretations.

This problem interpretation opens up the doors to use techniques fromthe MTL domain for AI-based Compression. Specifically, we are interestedin using Routing Networks for our pipeline. Routing networks are neuralnetworks that have multiple filter options per layer, and duringinference, the data itself decides which path it wants to take.

10.2 Routing Networks

A routing network [2] is a neural network for which the data flowthrough the network is not fixed but is routed. Let's assume we have aneural network that is composed of multiple layers. As a neural networkis simply a chronological concatenation of numerous functions, we canwrite these layers as functions ƒ and the network as ƒ∘ƒ∘ . . . ∘ƒ∘ƒ. Wecall the first layer ƒ_(X,1), the second layer ƒ_(X,2) and the n'thlayer ƒ_(X,N). A normal neural network has a fixed function that isexecuted per layer. However, a routing network has multiple options wecan pick from each layer. Let's assume there are M potential options topick from in each layer. We call option m∈M in layer n∈N functionƒ_(m,n).

An input to a routing network flows through all layers of the network{ƒ_(x,) ₁ ,1, . . . , ƒ_(x) _(N) ,N}. Nevertheless, at each layer, ithas to pick one specific function from the function filter bank→x_(i)∈M.Thus, various inputs could travel different routes through a fixedrouting network. For instance, input one could take the path {ƒ_(3,1),ƒ_(1,2), ƒ_(4,3), . . . , ƒ_(3,N)}; whereas input two could take thepath {ƒ_(7,1), ƒ_(8,2), ƒ_(4,3), . . . , ƒ_(2,N)}. FIG. 88 illustratesthis behaviour, by way of example.

In a routing network, the router, or Routing Module, decides the paththrough the network. There are numerous options for designing a router,a global, a local or a semi-local one (see FIG. 93 for example). For thesake of simplicity, we assume a local routing module. Let's assume wehave multiple local routers, input v, and (optional) meta information t.Then FIG. 89 visualises the flow of a typical routing network, by way ofexample.

-   -   Why does a routing network help (in general): A routing network        lets us scale the networks total memory footprint through much        bigger layers, but during inference, we pick only a subset of        the values, thus having a small memory footprint per inference        pass. An example: Assume our weight tensor is of shape        channels-in=192, channels-out=192, filter-height=5,        filter-width=5; our total amount of parameters are        192*192*5*5=921, 600. Assume our routing network, for the same        layer, has 100 potential weight tensors of shape channels-in=48,        channels-out=48, filter-height=5, filter-width=5. Our total        number of parameters are 100*48*48*5*5=5,760,000. But our        parameters for one specific function option in this layer is        merely 48*48*5*5=57,600. Overall, we get more flexibility and        more parameters, leading to better operation specialisation. But        we also get lower runtime, less parameter, and more        specialisation per route in the routing network.    -   Why does a routing network help (AI-based Compression): One        could argue that routing networks just shifts the complexity        away from the layers into the routing network; e.g. we get less        memory/flops in the layer but additional memory/flops in the        routing module. While this might, or might not, be true, it is        irrelevant for AI-based Compression. As previously mentioned, in        compression, we have a considerable time budget for encoding but        a minimal time budget for decoding. Thus, we can use asymmetric        routing networks to generate the routing information during        encoding and send this data in the bitstream as metainformation.        Therefore, we would not require the routing network's execution        during decoding but instead use the provided meta information.        We call this Asymmetric Routing Networks, and the concept is        shown in FIG. 90 , by way of example. Ultimately, this increases        our encoding runtime (irrelevant) but decreases our decoding        runtime (essential).

While it might be obvious, note that routing networks come with anexplosion of combinatorial possibilities for the final network. Let'sassume we have an eight-layer network ƒ=ƒ_(m,1)∘ƒ_(m,1)∘ . . . ∘ƒ_(m,1),and each layer has 16 possible choices; M={1, . . . , 16}. Then, thefinal network ƒ has 4 billion possible routes (M^(N)=16⁸=2^(4×8) 4, 294,967, 296). Thus, routing networks' power comes from its combinatoricalflexibility and from each route of the final network specialising in acertain input class.

For a more realistic illustration of how to use routing networks as theAI-based Compression pipeline, see FIG. 94 , by way of example.

10.2.1 Training the Routing Network

When training a routing network, there is one familiar and one new part.The familiar part is the network training through stochastic gradientdescent: we get the gradients from a loss function and backpropagatethem through all layers using the chain rule. Note that while the layerscan change with each iteration, this training approach still works. FIG.91 shows an example of the standard neural network training in the toppath.

The more interesting question is, how do we train the routing module?The difficulty from training the router is that the ideal output is adiscrete number m from our discrete set of options M. Thus, training therouter is no longer in the domain of gradient descent training butrequires reinforcement learning (RL) methods. Reinforcement learningfaces the same problem of selecting an “action policy” from a discreteset of options given a reward function. FIG. 91 shows an example of astandard RL training approach in the bottom path.

Finally, to build up some intuition about routing networks, the twotraining stages resemble two different trade-offs. Routing networksalways have the exploitation versus exploration challenge. While thestandard neural network resembles the exploitation part, the routingmodule choice resembles the exploration part. The challenge of trainingrouting networks is to train both parts of the network in parallel.

10.2.2 Training the Router

Following is a short overview of the different types of RL approaches totraining the routing module. In general, all possible RL methods can beused, with the most popular ones being:

1. Continuous Relaxation: Originally, we want the routing network tooutput a discrete choice. One approach is to relax this assumptionduring training and have the router output a vector of probabilitiesover the choices P_(n). We can write the next layer as a combination ofall possible choices with weight factors, as follows:

$\begin{matrix}{P_{n} = {Router}_{n}} & (10.2)\end{matrix}$${Layer}_{n} = {\sum\limits_{i = 0}^{M}\left( {{P_{n}(i)} \cdot {Layer}_{i,n}} \right)}$

Using a continuous relaxation of the discrete space allows us to usegradient descent training methods for training the router. Note that ininference, we replace the continuous relaxation with a discrete choiceusing the maximum function. For instance:

P _(n)=Router_(n)

Layer_(n)=Layer_(max(P) _(n) _(),n)  (10.3)

2. Discrete k-best choices: We can use all kinds of reinforcementlearning approaches on either the best choice or the k-best choices ofthe router with k∈{1, . . . , M} (these are also called highercardinality approaches). Amongst others, we can use: deep reinforcementlearning, Markov decision process, Dynamic programming, Monte Carlomethods, Temporal Difference algorithms, model free RL, model-based RL,Q-learning, SARSA, SARSA, DQN, DDPG, A3C, TRPO, PPO, TD3, SAC.

Finally, it is essential to complement the training approach foroptimising the loss/reward function for the routing module with adiversity loss. The diversity loss has to force the routing network toproduce diverse outputs (e.g. routes). Routing networks tend to havemuch stronger exploitation than exploration, and if there is noadditional loss forcing more exploration, they often collapse. In acollapsed routing network, the routing module only produces one routethrough the network; thus, losing out on its potential flexibility. Formore information, see reference [1].

10.2.3 Routing Networks and NAS

This is a short paragraph to link together some of our IP+concepts.Routing Networks are, in fact, a generalisation of Network ArchitectureSearch (NAS). In a more broad sense, they generalise the concepts ofNAS, Reinforcement Learning and One-shot Learning.

While NAS is about learning an efficient, fixed architecture for aneural network; routing networks are about learning multiple, efficient,flexible architectures for a neural network.

Thus, all the techniques used in NAS to make the network architectureselection more powerful, e.g. diversity in the layers, kernel size,operations and others, can also be used for routing networks. NAS issimple routing networks without routers: NAS+routing module+RL==RoutingNetworks. This is important as NAS and RL are their own gigantic domainof research. But we want to identify their methods for potentiallytraining our routing network.

10.3 the Routing Module

Now that we know the concept of Routing Networks, we must look at theRouting Module/Router. The job of the Router is to output data that willlead to a routing path decision. This could either be in the form of adiscrete choice {1, . . . , M} or a probability vector over the choices{p(m==1), . . . , p(m==M)}. Afterwards, we need some strategy to pick apath/route given this output, as described in section 2.2.

10.3.1 the Architecture of the Router

There is no a priori restriction on what the Router must look like. Forinstance, it could be feature-based, neural network-based, or anythingelse, as would be clear to the skilled person.

Feature-based Routers are approaches that make a decision on classicalcomputer vision features. For instance, we could use image statistics,histograms, gradient magnitude information, patch-wise features,feature-point extraction data such as FAST/SIFT/Others, Edge and/orCorners and/or Ridges detection, and many others. Feature-basedapproaches fix an image/video feature extraction method and then build alearning-based strategy (decision tree, regression, kernel PCA, supportvector machine, or others) on top of this information. The benefits fromthese approaches are that the feature-extraction reduces the problem'sdimensionality, from image space to feature space, and thus, leads to amassive Router runtime acceleration. Additionally, these approaches areusually resolution-independent and do not worry about different inputdata height and width.

Neural network-based Routers make a decision on deep-features and usethe power of deep learning to make the Router a universal functionapproximator. The benefits are that it makes the Router more potent thanclassical feature-based strategies and that we are not using a prioriinformation; everything is learned end-to-end. The drawback is that werequire the output to have a fixed form, and for this case, standardneural network architectures are not resolution-independent. We addressthis issue in the next section.

Some more advanced insights: The encoder and decoder module in theAI-based Compression pipeline look like inverse functions of each other.E.g. it seems as if the decoder has to learn the inverse mapping of theencoder. Interestingly, this relationship appears to hold true forlatent regions with high-probability mass, which means that the encoderand decoder's Jacobian are orthogonal at these points. If we use routingnetworks and make an encoder layer flexible, we need to pick the correctdecoding layer to complement the encoding layer change to keep theorthogonality. Thus, there should be information flow between allrouting modules, as the routing choice of a decoding layer should beinfluenced by the routing choice of the corresponding encoding layer. Tofacilitate optimal information sharing, local Routers have numerous skipconnections between each other, as visualised in FIG. 94 for example(see the horizontal lines).

10.3.2 Resolution Independent Neural Network Routers

There are multiple ways of making the Router resolution-independentwhile still using neural networks:

-   -   Adaptive Pooling: We can use an adaptive pooling layer with        fixed output, e.g. [1, 12, 20, 20], that pools all input shape        into the given output shape. Using adaptive pooling, e.g.        AdaptiveMaxPooling, AdaptiveAvgPooling and others, is common        knowledge in the Deep Learning field.    -   Permutation Invariant Set Networks: Originally, Set Networks        work by processing an arbitrary number of images with (optional)        skip connections and then having a pooling function as the        output of these networks (see section “Permutation Invariant Set        Networks” for example). For the Router, we can chop the input        data into overlapping or non-overlapping blocks and then use a        permutation Invariant Set Network. Why does this guarantee equal        shape outputs for arbitrary input shapes?Well, we fix the patch        size and thus have a fixed shape for the set network. If we have        a bigger input shape, we simply get more patches of the same        shape. FIG. 92 illustrates an example of using permutation        invariant set networks as routing modules to guarantee        size-independence when using neural networks as Routers.

10.3.3 Training the Router

It is essential to give special attention to the router training to getthe desired outcome. Routing networks, in general, have the challenge ofbalancing exploration versus exploitation. Specifically, it is a problemfor the Router. If we train the Routing Network AI-based Compressionpipeline naively, the Router will collapse and produce only one outputfor any input. Aka. the Router will 100% favour exploitation overexploration, and once it is stuck in a local minimum, it never recovers.

We can get around the collapse of the Router by facilitating explorationwith a “diversity loss”. Basically, a diversity loss is an additionalloss term that penalises the Router if it makes the same choice(selecting the same path) too many times. There are two choices for adiversity loss:

-   -   Temporal Diversity Loss: We keep track of past routing module        decision and penalise the temporal data/time series data for        more diversity. Meaning, the time-series data of the routing        module has to fit a particular distribution, for instance, the        uniform distribution. We can use any density matching method to        enforce this constraint.    -   Batch Diversity Loss: We can train over large-mini batches and        enforce routing-choice diversity over the mini-batch. Meaning,        the mini-batch routing choices have to fit a particular        distribution, for instance, the uniform distribution. We can use        any density matching method to enforce this constraint.

10.4 Concepts

-   -   1. Use of routing networks for AI-based Compression.    -   2. Routing Networks give performance and runtime improvement to        AI-based Compression through network specialisation.    -   3. Use of asymmetric routing networks for asymmetric        computational loads. This is especially useful for AI-based        Compression, but it is more general than this. In fact, the        concept is valid for any asymmetric tasks.    -   4. Use of various training methods for asymmetric routing        methods.    -   5. Routing methods are a generalisation of NAS+RL, thereby        including the techniques from these domains for routing        networks.    -   6. Reinterpreting AI-based Compression as a multi-task learning        (MTL) problem; thereby, opening the door to network        specialisation approaches. This includes the compression network        architecture but is not limited to it. For instance, it also        includes the loss function (e.g. various tasks require        specialised loss functions).    -   7. Use of the routing module data in the bitstream for other        postprocessing algorithms. The routing information contains        information about the class of compressed data. Thus, it can be        used, amongst others for (non-exclusive): image-search,        video-search, image/video filter selection, image/video quality        control, classification, and other tasks.    -   8. Information flow between the Routing Module is important when        applying the concept of routing networks to the AI-based        Compression pipeline due to its orthogonal property.    -   9. Permutation invariant set networks+chopping up the latent        space is suitable for resolution-independent Router        architectures.    -   10. Different ways a Routing Module's architecture can look like        (feature-based, neural network based, neural network        based+pooling, set networks).    -   11. Use of a diversity loss to train the Router.

10.5 Permutation Invariant Set Networks 10.5.1 Neural Networks Over Sets

Before diving into the individual sections on lens distortion andintrinsic calibration, we will first address how a learning basedapproach is possible over flexible sets of input data. After all, wewant to enable the user to select an arbitrary amount of images for thecalibration process, thus giving him a trade-off between performance vsaccuracy.

Permutation Invariance

Given more than one input for a naive network h(·), the order of theinputs does matter for the outcome. For instance, h(x₁, x₂, . . . ,x_(n))≠h(x_(n), x_(n−1), . . . , x₁). This becomes a challenge when wetry to apply deep learning to the problem of camera calibration for acollection of images. In essence, we want a network that considers theinput images as a set, independent of their order. This property iscalled permutation invariance.

There exist a number of options one can use, including sorting theinput, training an RNN with the desired property, or using a networkstructure that is symmetric with respect to the input. In fact, one mayargue that using a symmetric network is theoretically the preferredoption as it naturally ensures permutation invariance. It does notrequire additional augmentation and does not rely on any sortingheuristics. We can get a symmetric network h_(s)(·) by sharing weightsacross all inputs that are being processed: h_(s)(x₁, x₂, . . . ,x_(n))=h_(s)(x_(n), x_(n−1), . . . , x₁).

Cardinality Invariance

However, such a architecture can still only process a fixed amount ofinput images. We need a network that is agnostic to the amount of inputdata, thus is invariant to the cardinality of the input data set. Forthis, we need to accumulate the output of the shared networks via asymmetric accumulation operator ⊕, for instance element-wise mean,element-wise maximum or summation. Afterwards, we can (optionally)process the accumulated data further via another network g(·), which nowhas a fixed input size. Thus, the core structure of our networks is asfollows:

$\begin{matrix}{g\left( {\underset{i = 0}{\overset{{arbitrary}n}{\oplus}}\left( {h_{s}\left( x_{i} \right)} \right)} \right)} & (10.4)\end{matrix}$

10.5.2 Multi-Image, Global-State-Fusion Network

In this section well give an overview about the network architecture weuse for both the lens distortion parameter estimation as well as theintrinsic parameter estimation. First we will give an introduction tothe naive-version of the model, then introduce our contribution namedglobal state fusion into it.

Naive Architecture

As our model needs to work with arbitrary-sized sets of input images, wefirst have shared networks which operate on different input images. Weuse the term shared to mean that all networks share the same weightsacross the same layers. These networks use blocks of densely connectedconvolutional layers, interleaved with downsampling layers (conv-layers,stride two) to reduce the dimensionality. Moreover, we use multiple skipconnection via concatenations to aid proper gradient flow and reduce thevanishing gradient problem.

Second, after three downsampling operations, we fuse the outputs of theshared networks by averaging them as described in section “CardinalityInvariance”, followed by multiple fully connected layers to get ourparameters.

Global State Fusion Architecture

We now extend our above-described model by introducing global stateinformation into the shared networks. The key idea is that in the naivemodel the shared networks only have the information of one image, onlyfusing their individual knowledge at the end. In contrast, we want thenetworks to have global information at multiple points, and let themdecide if they use it or discard it.

Therefore, after each block of conv-layers we average the output of allshared networks, and concatenate this average global feature map stateto each one-image only feature map state. Thus, our shared networks doglobal state fusion multiple times during an iteration. Moreover,because we concatenate this information, the network can learn to whichextent it wants to utilize it.

Let's name the output of conv-block j in the i'th shared network o_(ij).Then before the next conv-block begins, we concatenate the networkspecific feature state o_(ij) with the global feature state õ_(j), whereby equals Σ_(k=1) ^(n)(o_(kj)). This operation keeps permutation andcardinality invariance. For an in-detail overview of the network seeFIG. 97 for example. In this figure, all conv. layers have a stride of 1and all downsample layers have a stride of 2. The concat columnrepresents the previous layers which are depth-concatenated with thecurrent input, a dash (-) represents no concatenation operation. Filterdim is in the format [filter height, filter width, input depth, outputdepth]. 5 represents the globally averaged state from output of allprevious blocks. The compress layer is connected with a fully connectedlayer with a thousand units, which are all connected to one unit whichregresses the parameter.

In FIG. 95 , symbol o_(ij) represents the output of the i'th image andj'th conv-block. ō is the average output over the previous conv-blocks.All conv-blocks across networks share weights and have a downsamplelayer at the end, shown by the block at the end of each rectangularlarger block. Dotted boundaries represent outputs, while solidboundaries are convolutions. For I_(n), arrows demonstrate how o_(n1)and ō are computed where) represents a symmetric accumulation operation.Fully connected layers are used to regress the parameter.

10.6 References

-   [1] Rosenbaum, Clemens, et al. “Routing networks and the challenges    of modular and compositional computation.” arXiv preprint    arXiv:1904.12774 (2019).-   [2] Rosenbaum, Clemens, Tim Klinger, and Matthew Riemer. “Routing    networks: Adaptive selection of non-linear functions for multi-task    learning.” arXiv preprint arXiv:1711.01239 (2017).

11. Padé Activation Units 11.1 Introduction

Activation functions, or nonlinearities, are function mappings thattransform the input space nonlinearly which are fundamental foreffective information processing in neural networks. The Padé ActivationUnit, or PAU, is a very efficient and generalised activation functionthat is capable of approximating many popular activation mappingscurrently employed in AI literature. This has still the capacity to beextended with variations in its parametrisation structure, evaluationalgorithms and stability mechanisms. Furthermore, a multivariate PAU isalso possible, extending the concept to process intervariablerelationships between the input variables.

Neural networks are famously able to model highly complex relationshipsbetween observed data and latent features. It owes most of this to theactivation functions, which grant the network its nonlinear modellingcapacity. Activation functions, or nonlinearities as they are oftencalled, are nonlinear function mappings that transform the inputtedfeature vector (or, simply, feature map) to an activated feature vector(or activation map). There exists a large variety of activationfunctions in deep learning literature, with names such as tanh, sigmoid,ReLU and Leaky ReLU being popular in the research field. Many of thesediffer in their functional expression, and there is little consensus ofwhich activation function to choose for a given optimisation task.Moreover, if the activation function is not sufficiently flexible (oreven fully static), this induces an arbitrary prior on the model. Thiscan either aid the network in its task if the activation function iswell-suited, or stifle its modelling capacity if it is poorly chosen.

A logical workaround would be to design and parametrise an activationfunction with ample degrees of freedom such that it can approximate mostof the common activation functions to a sufficient degree, as well asembody less conventional or even completely novel nonlinear mappings.Ideally, the number of parameters for this should be small to facilitatemodelling capacity and promote generalisation to the data. One elegantmethod for such a method is the Padé approximant.

The Padé approximant comprises a rational function

$\begin{matrix}{{f(x)} = \frac{p_{m}(x)}{q_{n}(x)}} & (11.1)\end{matrix}$

where p_(m) (·) is a polynomial of order m, q_(n)(·) is a polynomial oforder n and x is some arbitrary input. In full, the Padé approximant canbe expressed as:

$\begin{matrix}{{f(x)} = {\frac{a_{0} + {a_{1}x} + {a_{2}x^{2}} + \ldots + {a_{m}x^{m}}}{1 + {b_{1}x} + {b_{2}x^{2}} + \ldots + {b_{n}x^{n}}} = \frac{{\sum}_{j = 0}^{m}a_{j}x^{j}}{1 + {{\sum}_{k = 1}^{n}b_{k}x^{k}}}}} & (11.2)\end{matrix}$

As we shall see, with only a few parameters, the Padé approximant hasthe capacity to model virtually all activation functions that are usedin neural networks within a reasonable range of operation. With such ageneralised mapping, there is abundant design space for extending itsparametrisation to encourage expressivity or to limit it to promotegenerality. This mathematical construct is the foundation of theprovided activation function, the Padé Activation Unit or PAU, which weemploy within the domain of AI-based data compression.

The focus here is to

-   -   (a) present and outline in detail the Padé Activation Unit, its        associated configuration space and the possible variations and        extensions of this construct as a generic concept but under the        framework of machine learning;    -   (b) describe and exemplify the provided innovation in, but not        limited to, AI-based data compression in its present form.

11.2 Preliminaries

Please see Section 2.2 for mathematical preliminaries.

11.3 Padé Activation Units

Normally in neural networks, activation functions are interleaved withlinear and convolutional layers, with the optional normalisation andpooling layer. This is the usual structure of a module such as theencoder or decoder (see FIG. 98 for example). However, we willreasonably assume that the innovation in question will be discussedwithout further consideration of its point of application, but rather asa concept of its own that can be utilised in the capacity of anactivation function.

The innovation of the Padé Activation Unit will be clearly detailed inthe subsections below, comprised by the following:

-   -   Forward functional expression and associated parametrisation        structure, evaluation algorithm and stability mechanisms;    -   Backward functional expression and associated evaluation        algorithms and stability mechanism;    -   Variations in parametrisation structures;    -   Variations in evaluation algorithms;    -   Variations in numerical stability mechanisms;    -   Possible extensions to multivariate and higher-order variants of        PAU.

FIG. 99 shows an example of common activation functions in deep learningliterature such as ReLU, Tanh, Softplus, (bottom row, left to right)LeakyReLU and GELU. The PAU of order (m=5, n=4) can very precisely mimiceach mapping within the displayed range x∈[−3, 3].

11.3.1 Forward Function

In a forward (propagation) pass, the data is processed sequentiallythrough each neural network module and the forward functions of itssingular components. In the case of the PAU as activation function, forthe input hl, the forward functional expression is

$\begin{matrix}{h_{l + 1} = {{f\left( h_{l} \right)} = {\frac{p_{m}\left( h_{l} \right)}{q_{n}\left( h_{l} \right)} = {\frac{a_{0} + {a_{1}h_{l}} + {a_{2}h_{l}^{2}} + \ldots + {a_{m}h_{l}^{m}}}{1 + {❘{b_{1}h_{l}}❘} + {❘{b_{2}h_{l}^{2}}❘} + \ldots + {❘{b_{n}h_{l}^{n}}❘}} = \frac{{\sum}_{j = 0}^{m}a_{j}h_{l}^{j}}{1 + {{\sum}_{k = 1}^{n}{❘{b_{k}h_{l}^{k}}❘}}}}}}} & (11.3)\end{matrix}$

where (m, n) is the order of the Padé approximant and in effectdetermines the parametrisation structure of ƒ(·), given by α={a₀, a₁, .. . , a_(m)} ∈

^(m+1) and b={b₁, b₂, . . . , b_(n)} ∈

^(n). Initially, it is assumed that a and b are global parameters forthe activation layer (i.e. layer-wise activation function), but we shallsee in later subsections that we can easily extend this to achannel-wise parametrisation structure.

This expression differs from the formal definition of a Padé approximant(Equation (11.2)) in that the terms in the denominator are kept positivewith the absolute value operator. In its current form, the denominatorof the PAU is guaranteed to be larger than one. This is to ensure theabsence of poles causing numerical instabilities, which occurs when thedenominator evaluates to (or approaches) zero.

Since the PAU consists of two polynomials, we can leverage efficientpolynomial evaluation algorithms in our forward function. One suchefficient algorithm is Horner's method, which expresses a polynomial asfollows:

$\begin{matrix}\begin{matrix}{{p_{m}(x)} = {{a_{0} + {a_{1}x} + {a_{2}x^{2}} + \ldots + {a_{m}x^{m}}} =}} \\{= {a_{0} + {x\left( {a_{1} + {x\left( {a_{2} + \ldots + \left( {{x\left( {a_{m - 1} + {a_{m}x}} \right)}\ldots} \right)} \right)}} \right)}}}\end{matrix} & (11.4)\end{matrix}$

This algorithm requires m additions and m multiplications to run.Although it relies on serial execution where eachaddition/multiplication depends on the previous term, in most practicalapplications m is fairly low (see FIG. 99 for example). This means thealgorithm runs very quickly, and can even be sped up further byevaluating the two polynomials of PAU in parallel (see Algorithm 11.1).Furthermore, since we can modify the output in-place, it is alsomemory-efficient. In fact, the forward function of PAU requires roughly3N (where x∈

^(N)) in memory (two polynomials plus the input).

Algorithm 11.1 Forward function of (layer-wise.) ″safe″ PAU or order (m,n), using Horner's method for polynomial evaluations. Note that lines 6and 9 can be executed in parallel, allowing for a significantalgorithmic speedup. 1: Inputs:  h_(l) ∈

 ^(N): input feature vector  a = {a₀, a₁, ..., a_(m)} ∈

 ^(m+1): PAU numerator coefficients  b = {b₁, b₂, ..., b_(n)} ∈

 ^(n): PAU denominalor coefficients 2: Outputs:  h_(l+1) ∈

 ^(N): activated feature vector 3: Initialise:  p ← a_(m)1_(N)  q ←b_(n)1_(N) 4:

 1_(N) is a N-dimensional vector of ones 5: 6: for j ← m − 1 to 0 do   

 Can be parallelised with line 9 7:   p ← p ⊙ h_(l) + a_(j) 8: end for9: for k ← n − 1 to 1 do   

 Can be parallelised with line 6 10:  q ← |q ⊙ h_(l)| + b_(k) 11: endfor 12: q ← |q ⊙ h_(l)| + 1 13: memoryBuffer(h_(l), p, q, a, b)    

 Saved for backward pass 14: h_(l+1) ← p/q

11.3.2 Backward Function

The backward function is defined to allow for the gradients to flowthrough the PAU to upstream modules, as well as update the parameters{a, b}, during network training. Automatic differentiation packagesusually take care of the backpropagation process, however the backwardfunctions can also be custom-defined, such that their computation can beoptimised for (using CUDA kernels, for instance):

$\begin{matrix}{\frac{\partial f}{\partial h_{i,l}} = {{\frac{\partial p_{m}}{\partial h_{i,l}}\frac{1}{q_{n}\left( h_{i,l} \right)}} - {\frac{\partial q_{n}}{\partial h_{i,l}}\frac{p_{m}\left( h_{i,l} \right)}{{q_{n}\left( h_{i,l} \right)}^{2}}}}} & (11.5)\end{matrix}$ $\begin{matrix}{\frac{\partial f}{\partial a_{j}} = \frac{h_{i,l}^{j}}{q_{n}\left( h_{i,l} \right)}} & (11.6)\end{matrix}$ $\begin{matrix}{\frac{\partial f}{\partial b_{k}} = {{- {sign}}\left( b_{k} \right){❘h_{i,l}^{k}❘}\frac{p_{m}\left( h_{i,l} \right)}{{q_{n}\left( h_{i,l} \right)}^{2}}}} & (11.7)\end{matrix}$

Here, h_(i,l) is a scalar-element of the input vector,

$\frac{\partial p_{m}}{\partial h_{i,l}} = {a_{1} + {2a_{2}h_{i,l}} + {3a_{3}h_{i,l}^{2}} + \ldots + {ma_{m}h_{i,l}^{m - 1}{and}}}$$\frac{\partial q_{n}}{\partial h_{i,l}} = {{sign}\left( h_{i,l} \right){\left( {b_{1} + {2b_{2}h_{i,l}} + {3b_{3}h_{i,l}^{2}} + \ldots + {nb_{n}h_{i,l}^{n - 1}}} \right).}}$

These can also be evaluated using Horner's method or alternativepolynomial evaluation strategies.

Algorithm 11.2 Backward function of (layer-wise) “safe” PAU or order (m,n). In order to expedite processing speed, the polynomials p and q arestored in memory buffers from the forward function and subsequently usedin the backward pass.  1: Inputs  $\frac{\partial\mathcal{L}}{\partial h_{l + 1}}$ ∈

^(N): incoming loss gradient  2: Outputs  $\frac{\partial\mathcal{L}}{\partial h_{l}}$ ∈

^(N): outgoing loss gradient  $\frac{\partial\mathcal{L}}{\partial{\mathcal{a}}} = \left\{ {\frac{\partial\mathcal{L}}{\partial{\mathcal{a}}_{0}},\frac{\partial\mathcal{L}}{\partial{\mathcal{a}}_{1}},\ldots,\frac{\partial\mathcal{L}}{\partial{\mathcal{a}}_{m}}} \right\}$  ∈

^(m+1): loss gradients for PAU numerator coefficients  $\frac{\partial\mathcal{L}}{\partial b} = \left\{ {\frac{\partial\mathcal{L}}{\partial b_{1}},\frac{\partial\mathcal{L}}{\partial b_{2}},\ldots,\frac{\partial\mathcal{L}}{\partial b_{n}}} \right\}$ ∈

^(n): loss gradients for PAU denominator coefficients  3: Initialise  $\frac{\partial{\mathcal{p}}}{\partial h_{l}}\left. \leftarrow{a_{m}1_{N}} \right.$ $\left. \frac{\partial q}{\partial h_{l}}\leftarrow{b_{n}1_{N}} \right.$ h_(l), p, q, a, b ← memoryBuffer  4: Saved from forward pass  5:  6:for j ← m − 1 to 1 Can be parallelised with line 9  7:   $\left. \frac{\partial{\mathcal{p}}}{\partial h_{l}}\leftarrow{{\left( {j + 1} \right){\frac{\partial{\mathcal{p}}}{\partial h_{l}} \odot h_{l}}} + a_{j}} \right.$ 8: end for  9: fork ← n − 1 to 1 Can be parallelised with line 6 10:   $\left. \frac{\partial q}{\partial h_{l}}\leftarrow{{\left( {k + 1} \right){❘{\frac{\partial q}{\partial h_{l}} \odot h_{l}}❘}} + b_{k}} \right.$11: end for 12:$\left. \frac{\partial q}{\partial h_{l}}\leftarrow{{sign}{\left( h_{l} \right) \odot \frac{\partial q}{\partial h_{l}}}} \right.$13:$\left. \frac{\partial h_{l + 1}}{\partial h_{l}}\leftarrow{{\frac{\partial{\mathcal{p}}}{\partial h_{l}}/q} - {{\frac{\partial q}{\partial h_{l}} \odot p}/q^{2}}} \right.$14:$\left. \frac{\partial\mathcal{L}}{\partial h_{l}}\leftarrow{\frac{\partial\mathcal{L}}{\partial h_{l + 1}} \odot \frac{\partial h_{l + 1}}{\partial h_{l}}} \right.$15: $\frac{\partial h_{l + 1}}{\partial{\mathcal{a}}_{0}} = {1/q}$ 16:$\frac{\partial\mathcal{L}}{\partial{\mathcal{a}}_{0}} = {{\sum}_{i = 1}^{N}\left( {\frac{\partial\mathcal{L}}{\partial h_{l + 1}} \odot \frac{\partial h_{l + 1}}{\partial{\mathcal{a}}_{0}}} \right)}$17: forj ← 1 to m Can be parallelised with line 23 18:   $\frac{\partial h_{l + 1}}{\partial a_{j}} = {\frac{\partial h_{l + 1}}{\partial a_{j - 1}} \odot h_{l}}$19:   $\frac{\partial\mathcal{L}}{\partial a_{j}} = {{\sum}_{i = 1}^{N}\left( {\frac{\partial\mathcal{L}}{\partial h_{l + 1}} \odot \frac{\partial h_{l + 1}}{\partial a_{j}}} \right)}$20: end for 21:$\frac{\partial h_{l + 1}}{\partial b_{1}} = {{- {{❘h_{l}❘} \odot p}}/q^{2}}$22:$\frac{\partial\mathcal{L}}{\partial b_{1}} = {{\sum}_{i = 1}^{N}\left( {{sign}\left( b_{1} \right){\frac{\partial\mathcal{L}}{\partial h_{l + 1}} \odot \frac{\partial h_{l + 1}}{\partial b_{1}}}} \right)}$23: fork ← 2 to n Can be parallelised with line 17 24:   $\frac{\partial h_{l + 1}}{\partial b_{k}} = {\frac{\partial h_{l + 1}}{\partial b_{k - 1}} \odot {❘h_{l}❘}}$25:   $\frac{\partial\mathcal{L}}{\partial b_{k}} = {{\sum}_{i = 1}^{N}\left( {{sign}\left( b_{k} \right){\frac{\partial\mathcal{L}}{\partial h_{l + 1}} \odot \frac{\partial h_{l + 1}}{\partial b_{k}}}} \right)}$26: end for

11.3.3 Variations in Parametrisation Structure

The PAU can be parametrised such that its parameters are:

-   -   Global for the entire input vector (layer-wise PAU): each PAU is        parametrised by {α∈        ^(m+1), b∈        ^(n)} which is applied for every element in h_(l);    -   Partitioned for disaggregate components of the input vector,        such as channels (channel-wise PAU): each PAU is parametrised by        {A={α^([c])}_(c=1) ^(C)∈        ^(C×(m+1)), B={b^([c])}_(c=1) ^(C)∈        ^(C×n)}, where each a^([c]) and b^([c]) is applied on the        corresponding channel of the input vector,

$h_{l}^{\lbrack c\rbrack} \in {{\mathbb{R}}^{\frac{N}{C}}.}$

The partitioning can also be of finer structure, such as patch-wise orelement-wise.

11.3.4 Alternative Evaluation Algorithms

If the polynomial order of either p_(m) (·) or q_(n)(·) is large, we canemploy Estrin's scheme and evaluate the polynomial in parallel (assumingthat we have sufficient memory capacity). Given the polynomial or orderm, we can rewrite it in a way that allows for parallelism

$\begin{matrix}\begin{matrix}{{p_{m}(x)} = {{a_{0} + {a_{1}x} + {a_{2}x^{2}} + \ldots + {a_{m}x^{m}}} =}} \\{= {{\left( {a_{0} + {a_{1}x}} \right) + {\left( {a_{2} + {a_{3}x}} \right)x^{2}} + {\left( {a_{4} + {a_{5}x}} \right)x^{4}} + \ldots} =}} \\{= {r_{\lfloor{m/2}\rfloor}\left( x^{2} \right)}}\end{matrix} & (11.8)\end{matrix}$

where r_(└m/2┘)(x²) is a └m/2┘-degree polynomial in x². Every bracketedterm can be evaluated in parallel, hence the speed-up, and the schemecan operate further recursively, resulting in lower-degree polynomialsin higher orders of x.

Alternatively, when the parametrisation is static and not under weightoptimisation (so during deployment), Newton's method can be used tofactorise the polynomials and simplify or approximate the functionalexpression of the PAU forward pass in order to optimise for thealgorithmic evaluation speed and memory.

11.3.5 Variations in Numerical Stability Mechanisms

To avoid poles from arising in Equation (11.2), we implement “safe” PAUby restricting the terms in the denominator polynomial to nonnegativevalues. However, these can hurt expressivity and there may be betteralternatives for the forward function that also safeguard against poles.Some of the stability mechanisms that are possible are:

Alternative absolute valuing: We can ensure that the denominator isalways positive by taking the absolute value as such:

$\begin{matrix}{{f(x)} = {\frac{a_{0} + {a_{1}x} + {a_{2}x^{2}} + \ldots + {a_{m}x^{m}}}{1 + {❘{{b_{1}x} + {b_{2}x^{2}} + \ldots + {b_{n}x^{n}}}❘}} = \frac{{\sum}_{j = 0}^{m}a_{j}x^{j}}{1 + {❘{{\sum}_{k = 1}^{n}b_{k}x^{k}}❘}}}} & (11.9)\end{matrix}$

This is a more representative version of the Padé approximantformulation (Equation (11.2)) since it aggregates denominator termsbefore the absolute value is taken. However, the poles that otherwisewould cause discontinuities are now manifesting as sharp peaks ortroughs, which may disrupt the learning process.

Introducing b₀ with positivity constraint: We can replace the one in thedenominator polynomial with a bias term, b₀, which we have to restrictto be larger than zero for stability purposes:

$\begin{matrix}{{{f(x)} = {\frac{a_{0} + {a_{1}x} + {a_{2}x^{2}} + \ldots + {a_{m}x^{m}}}{b_{0} + {❘{b_{1}x}❘} + {❘{b_{2}x^{2}}❘} + \ldots + {❘{b_{n}x^{n}}❘}} = \frac{{\sum}_{j = 0}^{m}a_{j}x^{j}}{b_{0} + {{\sum}_{k = 1}^{n}{❘{b_{k}x^{k}}❘}}}}},} & (11.1)\end{matrix}$ b₀ > 0

We can do this with a small constant stability term, E, to the absolutevalue of b₀ such that no poles arise.

11.3.6 Multivariate PAU

As of yet, the PAU has only been discussed in terms of the inputdirectly, without modelling relationships between input variables. Itwould therefore be reasonable to consider the extension of the PAU tomultivariate PAU, which consists of the quotient of two matrixpolynomials

$\begin{matrix}{{f(x)} = {\frac{a_{0} + {A_{1}x} + {A_{2}x^{2}} + \ldots + {A_{m}x^{m}}}{1_{N} + {❘{B_{1}x}❘} + {❘{B_{2}x^{2}}❘} + \ldots + {❘{B_{n}x^{n}}❘}} = \frac{a_{0} + {{\sum}_{j = 1}^{m}A_{j}x^{j}}}{1_{N} + {{\sum}_{k = 1}^{n}{❘{B_{k}x^{k}}❘}}}}} & (11.11)\end{matrix}$

where the set of numerator coefficients, {α₀, A₁, A₂, . . . , A_(m)} areall matrices of dimensionality

^(N×N) except for α₀, which is an N-dimensional vector. Likewise for theset of denominator coefficients, {B₁, B₂, . . . , B_(n)}, which are all

^(N×N). To keep dimensionality tractable, it is likely that this schemewill be employed for partitions of the input, such that N is forinstance the number of channels. The matrix-vector product in each term,for example A₂x₂, can be expressed as a linear layer or a convolutionallayer with weight matrix A₂, for which the input elements will be takento the corresponding power.

In fact, the multivariate PAU as formulated above generalises theconcept of divisive normalisation, an operation in neuroscience,relating closely to how the visual cortex processes information.Assuming a bias term with a positivity constraint in the denominator,the multivariate PAU is very similar to the formulation of generaliseddivisive normalisation (GDN), a popular activation function in AI-basedimage compression

$\begin{matrix}{{f(x)} = \frac{Hx}{\left( {\beta + {\Gamma x^{2}}} \right)^{\varepsilon}}} & (11.12)\end{matrix}$

with the constraints that β_(i)>0, ∀β_(i)∈β and y_(i,j)≥0, ∀γ_(i,j)∈Γ.If e is all ones, this formulation is easily encapsulated in the schemeof multivariate PAU.

11.4 Concepts

In this section, we present the following concepts regarding the PadéActivation Unit as activation function. All concepts listed below areconsidered under the context of the wider domain of AI-based datacompression.

-   -   Application of the PAU as described here, with corresponding        forward and backward function algorithms and parametrisation        structure, as an activation function or other types of processes        within a neural network module.    -   Application of extensions to the PAU, with regards to        parametrisation structures, alternative evaluation algorithms        (both in training/inference and in deployment) and numerical        stability mechanisms.    -   Application of multivariate PAU, its associated parametrisation        structures, evaluation algorithms and numerical stability        mechanisms.

12. Fourier Accelerated Learned Image & Video Compression Pipeline withReceptive Field Decomposition & Reconstruction 12.1 Introduction

A goal for the current state of the art neural image and videocompression pipelines deployed for any type of streaming media ismassively reduced latency and computational cost to manage the demandsof modern and future VR streaming, cloud gaming, and any otherinnovative electronic media streaming service. Up until this point,there are no learned image and video compression pipelines capable ofthis feat. Here, we outline the building blocks for a neural image andvideo compression pipeline that runs wholly in the frequency domain torealize orders of magnitude lower latency and computational costscompared to any other published state of the art learned image and videocompression pipeline.

Image compression pipelines powered by deep neural networks have inrecent years been shown to consistently outperform the best traditionalimage compression codecs based on the High Efficiency Video Coding(HVEC) avd Versatile Video Codec (VVC). However for novel image andvideo applications such as live streaming, VR, AR and cloud gaming,satellite and medical imaging, 3D films, etc., these state of the artneural compression pipelines are still completely unsuitable due tostrict latency requirements, high resolutions and slow run-time. To meetthe stringent latency and compute restrictions of current and futuremedia streaming services we present novel neural compression buildingblocks created to realize learned image and video compression pipelinesin the spectral domain. A building block in state of the art neuralimage and video compression pipelines is the convolutional operationwhich constitutes close to all of the computational cost. Mathematicallya convolution with kernel & with the original image ƒ(x, y) may bedefined as in Equation (12.1).

$\begin{matrix}{{g\left( {x,y} \right)} = {{\omega \otimes {f\left( {x,y} \right)}} = {\sum\limits_{{dx} = {- a}}^{a}{\sum\limits_{{dy} = {- b}}^{b}{{\omega\left( {s,t} \right)}*{f\left( {{x + {dx}},{y + {dy}}} \right)}}}}}} & (12.1)\end{matrix}$

Within the field of machine learning, and more recently deep learning,several efforts have been published improving the performance ofconvolutions that involve very large kernels using the mathematicaltheorem known as the convolution theorem, shown in Equation (12.2) where

refers to the Fourier transformation. Briefly, the Fourier relatedtransformations also referred to as integral transformations, aremathematical operations that are typically employed to shift to a moreadvantageous domain to operate within. The advantage for an image andvideo compression pipeline to transform into a spectral domain isevident in Equation (12.2)—pointwise multiplications in the spectraldomain correspond to convolutions in the spatial domain, drasticallyreducing the number of floating-point operations.

{ƒ⊗g}=

{ƒ}*

{g}  (12.2)

The traditional building blocks of the learned image and videocompression pipeline such as convolutional layers, pooling layers, batchnormalization layers, activation layers, etc., do not work within thisdomain. There is no neural image and video compression pipelinesoperating completely in the frequency domain. The domain is stillunexplored—published research papers related to this area aresurprisingly scarce. In this document, these types of neural compressionpipelines of electronic media operating within the spectral domain mayalso be referred to as spectral compression pipelines. There are twolarge open questions within this niche field that most likely act as thebottleneck for academic and research interest:

-   -   1. What are good non-linearities within the frequency domain?    -   2. How do you perform up and downsampling?

Here we provide a novel toolkit of neural image and video compressionbuilding blocks to realize a neural image and video compression pipelinethat runs completely within the spectral domain—the first spectral imageand video compression pipeline.

12.2 Spectral Neural Image & Video Compression Toolkit

The building blocks utilized in our spectral compression pipeline willbe briefly discussed below.

12.2.1 Spectral Integral Transform

We utilized a Fourier related integral transformation known as theHartley Transformation. However, the specific integral transformationmay not be important as long as the transforms are continuous (integral)transforms of continuous functions. Thus, the following methods may beapplied in addition to the traditional Fourier Transformation: HartleyTransform, Wavelet Transform, Chirplet Transform, Sine and CosineTransform, Mellin Transform, Hankel Transform, Laplace Transform, andothers, for example.

12.2.2 Spectral Activation Function

As mentioned above, the traditional spatial neural activation functionsthat ensure non-linearity in typical learned compression networks maynot be employed in a spectral compression pipeline. This is because inthe spectral domain the effect of an activation function typicallyemployed in the spatial domain is mathematically completely different.As such a variety of spectral specific activation functions wereimplemented, such as the spectral non-linear activation seen in Equation(12.3) below, where F_(conv) _(a) and F_(conv) _(b) represent spectralconvolutional operations, each with a different learnable kernel. InEquation (12.3) the operator “*” refers to a pointwise multiplication inthe spectral domain and conversely a convolution in the spatial domain.

F _(act)(x)=F _(conv) _(a) (X)*F _(conv) _(b) (x)  (12.3)

12.2.3 Spectral Convolutional Layer

An immediate limitation of spectral convolutions, based on Equation(12.2) is that pointwise multiplication between the kernel ω and imageƒ(x, y) necessarily requires that the shapes match. A method wasimplemented to ensure that the kernel ω and input ƒ(x, y) are ofcompatible shapes.

12.2.4 Spectral Upsampling & Downsampling

A spectral based learned compression pipeline may not necessarilyrequire image scaling in the same sense as for traditional neural imagecompression. Nevertheless, as a way of achieving additional performancebenefits a novel type of upsampling and downsampling was createdspecifically for the spectral domain, shown below in FIGS. 100(a) and100(b).

Specifically in FIG. 100(a) the input is divided into severalblocks—four blocks in the figure—that are concatenated in a separatedimension. A convolution operation with a 1×1 kernel is then appliedsuch that the number of channels is reduced by half. The upsamplingfollows a reverse and mirrored methodology.

12.2.5 Spectral Receptive Field Based Decomposition & Reconstruction

Two varieties of receptive field based spectral image decomposition andimage reconstruction for the spectral compression pipeline are discussedin this section.

The image decomposition is known as stacking: smaller image patches orblocks are stacked in a new dimension, whereas the image reconstructionis known as stitching. Specifically, a window of size W_(H), W_(W)slides across the image based on a stride S_(H), S_(W). For each windowposition, a patch is created that is stacked in a batch dimension. Theoverlap between successive windows is based on the difference betweenthe window size and the stride, for an example see FIG. 101 .

When reconstructing the image back together there are two methods ofstitching. Firstly by stitching with the overlapping regions averaged(see FIG. 102 for an example of executing an averaging mask). Secondlyby stitching it back together such that there are no overlapping regionsto account for.

12.3 Concepts

-   -   1. Executing an entire AI-based Compression pipeline in the        Frequency Domain. This realises massive speedups. Required        building blocks are listed here.    -   2. Use of Spectral Convolution for AI-based Image and Video        Compression.    -   3. Use of Spectral Activations for AI-based Image and Video        Compression.    -   4. Use of Spectral Upsampling and Downsampling for AI-based        Image and Video Compression.    -   5. Use of a Spectral Receptive Field Decomposition Method for        AI-based Image and Video Compression.

13. AI-Based Compression and Neural Architecture Search 13.1Introduction

Neural Network Architecture Search (NAS) is an approach in which weattempt to remove human bias from decision-making regarding neuralnetwork architecture design. AI-based Compression is an approach inwhich we attempt to remove human bias from designing a compressionpipeline to get to the next generation of compression technology. Intheir core approaches, AI-based Compression and NAS overlap. It is thenext step to apply NAS to the network design of AI-based Compression toalso remove human bias in the codec design.

Here we describe methods (NAS) of determining one or multiple candidatearchitectures for a neural network for performing AI-based Image/VideoCompression for different use cases. These methods include: maintaininga sequence of neural layer (or operator) selection processes, repeatedlyperforming the candidate architecture forward pass, updating the NeuralArchitecture Search system by using the feedback of the currentcandidate sets, and selecting one, or a group, of candidates of neuralarchitectures as the final AI-based Image/Video Compression sub-system;or as a particular function module for the final AI-based Image/Videocompression sub-system.

The innovations include applying the NAS-process to

-   -   The AutoEncoder of the AI-based Image and Video Compression        pipeline; and/or    -   The Entropy Model of the AI-based Image and Video Compression        pipeline; and/or    -   The loss function of the AI-based Compression (discriminative &        generative); and/or    -   The assumed model-distribution over the latent space of the        AI-based Compression pipeline

with the goals of getting

-   -   faster decoding runtimes during inference;    -   faster encoding runtimes during inference;    -   faster training runtime;    -   faster training network convergence;    -   better loss modelling of the human-visual-system;    -   better probability model-distribution selection and/or creation;    -   better entropy modelling through better density matching;    -   optimising platform (hardware architecture) specific goals.

Let us define a few NAS related terms:

-   -   Operator/(Neural) Layer: A possible operation/function that we        apply to input to transform it. For instance: Tanh, Convolution,        Relu, and others.    -   Neural Architecture: A set of hyperparameters which detail the        organisation of a group of operators.    -   (Neural) Cell: A repetitive structure that combines multiple        operations.    -   Search Space: The space over all possible combinations and        architectures given some constraints.    -   Search Strategy: A method that outlines how we want to explore        the search space.    -   Performance Estimation: A set of metrics that measure or        estimate how well a specific neural architecture performs given        a specific loss objective.    -   Micro Neural Search: Searching for a neural cell that works well        for a particular problem.    -   Macro Neural Search Searching to build the entire network by        answering questions such as the number of cells, the connections        between cells, the type of cells and others.

Here we apply NAS to optimal operator selection, optimal neural cellcreation, optimal micro neural search, optimal macro neural search underthe context of AI-based Image and Video Compression. We will considerdifferent performance estimation methods and search space limitations toreduce search times; and use efficient search strategies.

13.2 Operator Selection

For operator selection, the question is which function should we use atwhich position in the neural network. Given a fixed-architecture and aset of pre-selected operators, picking the best ones becomes achallenge. For example, suppose the set of possible operators is asfollows:

O={convolution-layer-1×1, convolution-layer-3×3, convolution-layer-5×5,convolution-layer-7×7, activation-function-1, activation-function-2,activation-function-3, activation-function-4, Identity Function, SkipConnection, Attention-Module, adding bias, . . . }

Each time we select an operator in the network we must pick a specificfunction from O→ƒ_(i)∈O. FIG. 103 shows an example which illustratesthis process within an AI-based Compression pipeline.

Once we have O defined, the question becomes, how can we train such anetwork, and how can we select one operator per function. In general,there exist two approaches:

-   -   1. We can treat the problem as a discrete selection process and        use Reinforcement Learning tools to select a discrete operator        per function. Reinforcement Learning treats this as an        agent-world problem in which an agent has to choose the proper        discrete operator, and the agent is training using a reward        function. We can use Deep Reinforcement Learning, Gaussian        Processes, Markov Decision Processes, Dynamic Programming, Monte        Carlo Methods, Temporal Difference algorithm, and other        approaches in practice.    -   2. We can use Gradient-based NAS approaches by defining ƒ_(i) as        a linear (or non-linear) combination over all operators in O.        Then, we use gradient descent to optimise the weight factors in        the combination during training. It is optional to include a        loss to incentive the process to become less continuous and more        discrete over time by encouraging one factor to dominate (e.g.        GumbelMax with temperature annealing). In inference, we use only        one operation, the operation with the highest weight-factor.

Note that such a setup can give us additional possibilities to modelnon-standard loss objectives. For instance, we can associate auxiliaryvariables with the operators such as runtime, FLOPs, memory usage andothers. Suppose we use these auxiliary terms in the loss equation. Inthat case, this gives us a straightforward way to optimise our pipelinefor objectives such as runtime, computational complexity, memory usage,and others.

13.3 Macro Architecture

To search for an optimal Macro Architecture, we have two options: Eitherwe start with a massive network and select strategies to pruneconnections/filters/weights (top-down approach) or build up an efficientarchitecture from scratch (bottom-up approach). There are alsomixed-approaches which iterate between pruning and building (e.g.MorphNet).

We can combine any of these methods with AI-based Compression specificauxiliary losses. For instance, we select a pruning-approach and addruntime/memory/FLOPS/visual-quality/filesizes constraints to eachoperation and connection to train an optimal final model for ourparticular objective. FIG. 104 provide an example of this approach forthe Encoder (can be applied to any part of the pipeline). Well-known NASapproaches that we can use at this stage are (versions of DARTS):Continuous relaxation of the search space where each edge is a mixtureof all candidate operations, joint optimization of the probability ofmixed operations and network weights, and discrete searched neuralarchitecture using reinforcement learning techniques or evolutionaryalgorithms.

The Macro Architecture design's bottom-up approach relies onSupernetworks (Also called: controller networks, mother networks). Wehave an architecture we want to optimise (AI-based Compressionpipeline), also called child-network, and a controller determining howgood a child-network is. Known approaches are early-stopping criteria,building up result tables and using RL on these result-tables, usingaccuracy predictors. Examples include: FBNet, SparseNAS, and others.FIG. 105 provides an example of Macro Architecture Search with abottom-up approach using a controller-network.

13.4 Concepts

-   -   Using NAS's Macro-Architecture approaches to find better neural        architectures for the AI-based Compression pipeline at: the        Encoder, Decoder, Quantisation Function, Entropy Model,        Autoregressive Module and Loss Functions.    -   Using NAS's Operator-Search techniques to find more efficient        neural operators for the AI-based Compression pipeline at: the        Encoder, Decoder, Quantisation Function, Entropy Model,        Autoregressive Module and Loss Functions.    -   Combining NAS with auxiliary losses for AI-based Compression for        compression-objective architecture training. These auxiliary        losses can be runtime on specific hardware-architectures and/or        devices, FLOP-count, memory-movement and others.

14. Finetuning of AI-Based Image and Video Compression Algorithms 14.1Introduction

AI-based compression uses neural networks that are trained to performwell and generalize across all inputs. However this leads room forimprovement on a per-input basis (say, for one particular image orvideo). The role of finetuning is to improve an AI-based compressionpipeline on a per-input basis. Here we outline several approaches:finetuning the latent variables; finetuning the decoder network'sweights (parameters); and finetuning the decoder's execution path.

In a compression pipeline, an encoder sends a media file as a binarystream of bits. The encoder sends this bitstream to a decoder, whichattempts to reconstruct the original media file from the bitstream.There are two competing tasks: on the one hand, the encoder wants tosend as few bits as possible; yet on the other hand, the reconstructedmedia file should be as close as possible to the original file. This isthe so-called “rate-distortion trade-off”: the compression pipeline mustsomehow minimize both rate (number of bits), and distortion, thereconstruction error between the original and decoded files.

Before delving into the rate-distortion trade-off, let's first outline ageneric AI-based compression pipeline (see FIG. 106 for example). Themedia file to be compressed is a real-valued vector x∈

^(M)(such as an image or a video file) in an M-dimensional space. In anAI-based compression pipeline, the encoder is a function E:

^(M)

^(n), typically parameterized by a neural network. The encodertransforms the media into a latent vector y=E(x), y being a real-valuedvector in an n-dimensional space. Usually n<M, so that the latent livesin a smaller dimensional space than the original media file.

Now, the pipeline must somehow turn the latent y into a binarybitstream. This is accomplished as follows. First, the latent y isquantized into a integer-valued vector ŷ. This quantized latent is givento a probability (entropy) model, which assigns a likelihood of eachelement in the latent occurring. These likelihoods are then sent to anarithmetic encoder, turning the likelihoods into a bitstream. Thebitstream is what is actually sent by the encoder. On decode, anarithmetic decoder reverses the binarization procedure, taking binaryvalues, likelihoods, and returning a faithful reproduction of ŷ. Thisrecovered quantized latent is then sent through a decoder neuralnetwork, returning the final prediction=D(y).

14.1.1 Network Training & the Rate-Distortion Trade-Off

How do we actually ensure that the prediction is as close as possible tothe original input media x? Moreover, how do we control length of thebitstream (number of bits)?

These two issues are resolved during network training. Each of theencoder E, quantization function Q, probability model P, and decoder Dmay be parameterized by a large vector θ (sometimes called networkweights). The parameters θ can be thought of as dials controlling thebehaviour of the entire pipeline, and must be optimized. The parametersare chosen to minimize (1) the distortion between and x, and (2) therate (length) of the bitstream.

During network training, the rate can be estimated without running thearithmetic encoder/decoder, using a rate estimation function R (see FIG.106 for example). The rate estimation function provides an upper boundon the number of bits that the arithmetic encoder will use. A distortionfunction dist:

^(M)×

^(M)

is chosen to measure the difference between x and {circumflex over (x)}.These two quantities, rate aha distortion, are combined into a valuecalled the loss,

:=R (ŷ)+λdist({circumflex over (x)}, x). A small loss means that thecompression pipeline performs well. The coefficient λ>0 controls therelative importance of the distortion compared to the rate. Highervalues of A mean that the loss cares more about minimizing distortionthan minimizing rate; low values of A mean that the loss cares moreabout minimizing the rate (bitstream length).

The training procedure then attempts to minimize the rate-distortionloss over all input media files. That is, the training procedure triesto find a set of parameters θ that work equally well across all typicalinput media. In mathematical terms, the training procedure attempts tosolve the optimization problem

$\begin{matrix}{\min\limits_{\theta}{\underset{x}{\mathbb{E}}\left\lbrack {{R\left( \overset{\hat{}}{y} \right)} + {\lambda{{dist}\left( {x,\overset{\hat{}}{x}} \right)}}} \right\rbrack}} & (14.1)\end{matrix}$

The symbol

is the expectation symbol, which means that the loss should be minimizedin expectation (on average), over all possible media inputs. That is,during training we try to find parameters θ (for the encoder, decoder,quantization function, and probability model) that work well on average.Though obviously it is not possible to train a compression pipeline overall inputs (there are infinitely many), modern training methods arestill able to find parameters θ that generalize well, so that thepipeline's compression performance generalizes to unseen typical images.

14.1.2 the Need for Finetuning

This points to the need for finetuning. The optimization procedure doesnot consider finding parameters that are particularly good for any oneparticular media file. Once training is finished, we have a set ofparameters that work “pretty good”—the encoder, decoder, quantizationfunction, and probability model all perform reasonably well on typicalinputs. In other words, the compression pipeline generalizes well; butit is not specialized to perform superbly on any one particular image.It is a “jack of all trades, but master of none”.

The question that arises is then, can we somehow boost the performanceof the compression algorithm on a case-by-case basis? I.e. given aparticular input, can we design a per-image algorithm that improves thecompression algorithm on a per image basis? This is the processoffinetuning. Finetuning seeks to bring out extra compressionperformance (either in rate, or distortion, or both) on a per-inputbasis. Finetuning takes the already “pretty good” compression algorithm,which generalizes well, and somehow specializes the algorithm to performvery well on a particular input.

Example 1. To illustrate the idea, consider the following toy example,illustrated in FIG. 107 by way of example. Suppose we have a set ofpoints {x₁, x₂, . . . , X_(k)}, and we want to find a parameter θ thatis the closest, on average, to all other points. (In this exampledisregard rate.) The optimization procedure would be to find

$\begin{matrix}{\min\limits_{\theta}\frac{1}{k}{\sum\limits_{i = 1}^{k}{{dist}\left( {\theta,x_{i}} \right)}}} & (14.2)\end{matrix}$

See for example FIG. 107(a), where the optimal 0 is plotted for some toydata. Now however, on a per-instance basis this 0 is not the bestchoice: if we want to minimize distance to a particular point, say x₁ inFIG. 107(b), 0 is actually quite far away. Of course the best choice inFIG. 107(b) is x_(i) itself. In this example, 0 generalizes well, inthat it is the closest point to all other points, but it is not theclosest to any one particular point.

Here we are concerned with all possible ways of finetuning an AI-basedcompression algorithm. We consider three broad ways of finetuning:

-   -   1. Finetune latent variables (ŷ) (see Section 14.2). In general,        the idea of latent finetuning is to replace the quantized        latents ŷ returned by the encoder E with “better” latents. These        new latents could improve the rate, the distortion, or some        other metric.    -   2. Finetune the decoder function (see Section 14.3), so-called        functional finetuning. Broadly, the idea here is to send a small        amount of additional “side-information” in the bitstream, that        will modify the decoder D so that it is better adapted to the        particular image at hand.    -   3. Architectural finetuning (see Section 14.4). This is a        slightly different than previous point, although related. In        architectural fine tuning, the neural network path of the        decoder is modified, by sending additional information to        activate/deactivate some of the operations executed by the        decoder, on a per-instance basis.

14.2 Innovation: Latent Finetuning

In this section we discuss the technique of latent finetuning, andpossible instances of this technique. The basic framework algorithm forlatent finetuning works as follows (refer to Algorithm 14.1). For aparticular input x, the finetuning algorithm begins by initializing withthe quantized latents first produced by the encoder, setting ŷ₀=Q(E(x)).The initial latents ŷ₀ are generic latents, produced by the compressionalgorithm optimized to perform well on all possible inputs. Thesegeneric latents will be modified (finetuned) in some way to improve thecompression performance. In a loop, the latent finetuning algorithmiteratively improves the latents, progressively perturbing the latentsso that some performance metric

Algorithm 14.1 A framework for latent finetuning algorithms 1: Input:   input media x ∈

 ^(M), encoder ∈ :

 ^(M )

 ^(n),decoder D :

 ^(n)  

 

 ^(M),    finetuning loss

 :

 ^(M) ×

 ^(M) ×

 ^(M) 

 

2: Initialize:    set ŷ₀ = Q(E(x)); {circumflex over (x)}₀ = D (ŷ₀) 3:while ŷ_(k) not optimal do 4:    evaluate

 (x, ŷ_(k), {circumflex over (x)}_(k)) 5:    generate perturbation p 6:   update ŷ_(k+1) ← ŷ_(k) + p 7:    get decoder prediction {circumflexover (x)}_(k+1) ← D(ŷ_(k+1)) 8:    k ← k + 1 9: end while 10: Output:   finetuned latent ŷ_(k)of the compression pipeline improves. The performance of the compressionpipeline is measured by a finetuning loss

, which could for example measure:

-   -   the rate (bitstream length) of the new perturbed latent ŷ_(k);    -   the distortion between the current decoder prediction        {circumflex over (x)}_(k) and the ground-truth input X;    -   or other measures, like the distortion between the current        decoder prediction k and the original decoder prediction        {circumflex over (x)}₀;    -   or a combination of any of the above.

At each iteration of the loop, a perturbation is generated, which isused to modify the latent. Perturbations are generated to improve thefinetuning loss in some way. The prediction {circumflex over (x)}_(k) iscreated from the current latent (which may be needed to determine howwell the new latent performs, e.g. with respect to distortion). Theiteration the begins anew. The loop ends when the latent is deemedoptimal in some sense, and returns the finetuned latent.

Why is latent finetuning necessary? Remember that in a trained AI-basedcompression pipeline, the encoder E is optimized to perform well on alltypical inputs; E is generalized, not specialized to the particularinput at hand. Thus it is very likely that the initial latent ŷ₀=Q(E(x))is not the best latent for the particular input x, and that we canimprove on the latent in some way. Notably, changing the latent ŷ maycome with no increase to the bitstream length: no additional informationis needed if we perturb ŷ in a sensible fashion (compare this with themethods of Sections 14.3 and 14.4, where extra information [bits] mustbe sent).

In mathematical language, the finetuning algorithm detailed in Algorithm14.1 seeks to solve the following optimization problem

$\begin{matrix}{\min\limits_{\overset{\hat{}}{y}}{\mathcal{L}\left( {x,\overset{\hat{}}{y},\overset{\hat{}}{x}} \right)}} & (14.3)\end{matrix}$

where

is the finetuning loss; and {circumflex over (x)}=D(ŷ) is the output ofthe decoder.

The latent finetuning framework can be fleshed out in various ways. Forexample,

-   -   the finetuning loss can be customized in any number of ways,        depending on the desired properties of the latent and the        prediction (see Section 14.2.2)    -   the perturbation can be generated from a host of strategies (see        Section 14.2.3)    -   the variable stopping criteria must be specified in some way    -   the latents could themselves be parameterized, so that the        finetuning algorithm performs updates in a parameterized space        (refer to Section 14.2.1)

The remainder of this section will flesh out these various modificationsto the latent finetuning framework.

14.2.1 Choosing the Variable to be Finetuned

The variable ŷ is ultimately the variable sent (via the probabilitymodel, c.f. FIG. 10 ⁶, for example) to the arithmetic encoder, and so itis the most natural variable to be finetuned.

This is sometimes called STE finetuning (STE being short for “straightthrough estimator”). However, note that ŷ is the output of a series oftransformations, in particular ŷ depends on y and x. Therefore, ratherthan finetuning ŷ itself, we could “pull-back” the optimization to anyone of the prior variables in the compression pipeline (e.g. any one ofthe prior variables to ŷ in FIG. 10 ⁶). Note that, once optimization isfinished, we would calculate ŷ from the optimized prior variable, and ŷis still the variable that is sent to the arithmetic encoder.

So for example, rather than optimizing ŷ, we may optimize y. Themathematical problem to be solved then is

$\begin{matrix}{\min\limits_{y}{\mathcal{L}\left( {x,{\overset{\hat{}}{y} = {Q(y)}},{\overset{\hat{}}{x} = {D\left( {Q(y)} \right)}}} \right)}} & (14.4)\end{matrix}$

Note the subtle difference to Equation (14.3). The optimization variableŷ has been replaced with y. And in the finetuning loss, we have made therelationship between ŷ and y clear by explicitly setting ŷ=Q(y). Howdoes this change affect Algorithm 14.1? Because now the optimization isperformed on the unquantized latent, initialization begins by settingy₀=E(x). Perturbations will be generated for the variable y_(k), and theupdate will be y_(k+1)←y_(k)+p. Wherever ŷ_(k) is needed in thealgorithm, it will be calculated on the fly as ŷ_(k)=Q(y_(k)).

As another example, the variable to be optimized could be the input tothe entire compression pipeline. Let's denote a generic input as {tildeover (x)}, and the specific image at hand as simply x. The mathematicalproblem to be solved then is

$\begin{matrix}{\min\limits_{\overset{\sim}{x}}{\mathcal{L}\left( {x,{\overset{\hat{}}{y} = {Q\left( {E\left( \overset{\sim}{x} \right)} \right)}},{\overset{\hat{}}{x} = {D\left( {Q\left( {E\left( \overset{\sim}{x} \right)} \right)} \right)}}} \right)}} & (14.5)\end{matrix}$

The optimization variable here is {tilde over (x)}, which effectivelyparameterizes ŷ via a pull-back ŷ=Q(E({tilde over (y)})). The changes tothe framework Algorithm 14.1 are that: (1) initialization begins with{tilde over (x)}₀=x; (2) perturbations are generated for {tilde over(x)}, so that the update rule is {tilde over (x)}_(k)←{tilde over(x)}_(k)+p. Whenever ŷ is needed, it is calculated as ŷ_(k)=Q(E({tildeover (x)}_(k))).

14.2.2 Designing the Finetuning Loss

The finetuning loss, which measures how well the latent performs, playsa critical role in the finetuning algorithm. The finetuning loss may beused to generate the perturbations of the latent in the latent. Inaddition, the finetuning loss may be used to decide when to stop theiterations of the finetuning algorithm. The finetuning loss couldmeasure

-   -   the distortion between the prediction returned by decoding the        fine tuned latent, and the original input image. In mathematical        terms, this is written dist(x, D(ŷ)), where {circumflex over        (x)}=D(ŷ) is the decoded prediction of the finetuned latents.    -   the distortion between the original prediction (created from the        original latents), and the prediction created by the finetuned        latents. In mathematical terms, this is written dist({circumflex        over (x)}_(orig), {circumflex over (x)}_(ft)), where {circumflex        over (x)}_(orig) and {circumflex over (x)}_(ft)) are        respectively the original and finetuned predictions from the        decoder, created using the original and finetuned latents.    -   the rate (bitstream length), or an estimate of the rate (e.g.        using the cross-entropy loss).    -   regularization quantities of the predicted output. This includes        quantities such as Total Variation, a measure of the regularity        of the output image.    -   any combination of the above

There are many possibilities for what the distortion metric in thefinetuning loss. Possibilities include

-   -   any of the        _(p) norms, including Mean Squared Error    -   distortion metrics in a particular colour space, such as        CIELAB's ΔE*. These distortion metrics are designed to be        perceptually uniform to the human eye, so that changes are        accurately captured across all colours    -   hard constraints that prevent the distortion from increasing        above a certain threshold    -   Generative Adversarial Network (GAN) based distortion metrics.        GAN-based distortion metrics use a separate “discriminator”        neural network (different from the neural networks in the        compression pipeline), whose job is to determine whether or not        an image (video, etc) is naturally occurring. For instance, a        discriminator could be trained to determine whether or not        images are real (natural, uncompressed), or predicted (from a        compression pipeline). In this example, minimizing the        distortion metric would mean “fooling” a GAN-based        discriminator, so that the discriminator thinks compressed        images are real.

14.2.3 Strategies for Perturbing the Latent

Algorithm 14.1 provides a framework for perturbing the initial latentvector ŷ, however it lacks details of how the perturbation is actuallyconstructed. There are many possibilities; this section will discusssome possible strategies for perturbing the latent.

Gradient Descent and Other 1st-Order Optimization Methods

The perturbation vector p of Algorithm 14.1 may be found by using a1st-order optimization method, which solves the particular minimizationproblem (e.g. equations (14.3), (14.4), and (14.5)). A 1st-orderoptimization method is any method that approximates the loss (in thiscase, the finetuning loss), using the loss value at a point, and itsgradient at this point (the direction of steepest ascent). So forexample, the gradient descent method could be used to update thelatents:

ŷ _(k+1) =ŷ _(k)−τ∇_(ŷ)

(x,ŷ _(k) ,{circumflex over (x)} _(k))  (14.6)

Here ∇_(ŷ)

is the gradient of the finetuning loss, with respect to the latentvariable ŷ. To be explicit, the perturbation is given by p=−τ

(x, ŷ, {circumflex over (x)}_(k)). The scalar τ is a small parameterthat controls the magnitude of the perturbation, the so-called“step-size”. τ can be calculated using any step-size rule.

This is just one of many 1st-order optimization methods. Other examplesof 1st-order optimization methods that may be used are: Adam; anyaccelerated 1st-order method such as Nesterov's momentum; and proximalgradient methods.

The 1st-order optimization method can be applied to any one of thevariables discussed above in the latent finetuning optimization methods(e.g. problems (14.3), (14.4), and (14.5)).

2nd-Order Optimization Methods

2nd-order optimization methods may also be used. A 2nd-orderoptimization method is like a 1st-order optimization method (using theloss value and its gradient at a point), but also uses the Hessian (thematrix of second-order derivatives of the loss). In a 2nd-orderoptimization method, the perturbation p is chosen to minimize a2nd-order approximation of the finetuning loss

$\begin{matrix}{{\underset{{p} < \tau}{\min}{\mathcal{L}\left( {x,{\overset{\hat{}}{y}}_{k},{\overset{\hat{}}{x}}_{k}} \right)}} + {p^{T}{\nabla_{\overset{\hat{}}{y}}{\mathcal{L}\left( {x,{\overset{\hat{}}{y}}_{k},{\overset{\hat{}}{x}}_{k}} \right)}}} + {\frac{1}{2}p^{T}{\nabla^{2}{\mathcal{L}_{\overset{\hat{}}{y}}\left( {x,{\overset{\hat{}}{y}}_{k},{\overset{\hat{}}{x}}_{k}} \right)}}p}} & (14.7)\end{matrix}$

Here ∇_(ŷ) ²

is the Hessian of the finetuning loss. The perturbation p is chosen tobe no larger than some step-size threshold τ (the search radius).

The expression

p can be evaluated using efficient automatic differentiation techniquessuch as the Hessian-vector product.

Note that the perturbation may also be constrained so that the update tothe quantized latents is still an integer-valued vector. In this case,the problem is a quadratic-integer valued problem, which can be solvedusing algorithms for the Closest Vector Problem.

Monte-Carlo, Metropolis-Hastings, Simulated Annealing, and Other GreedyApproaches

The latent perturbation need not be generated explicitly from localapproximations of the finetuning loss (as in the previous twosubsections, which used gradient and Hessian information). Theperturbation could be chosen as a vector from a random distribution.This is the idea behind Monte-Carlo methods and their many variants.

Algorithm 14.2 A framework for Monte-Carlo-like latent finetuning 1:Input:    input media x ∈

 ^(M), encoder E :

 ^(M )

 

 ^(n), decoder D :

 ^(n) 

 ^(M),    finetuning loss

 :

 ^(M) ×

 ^(M) ×

 ^(M) 

 

2: Initialize:    set ŷ₀ = Q(E(x)); {circumflex over (x)}₀ = D (ŷ₀) 3:While ŷ_(k) not optimal do 4:    sample perturbation p ~ P 5:    setcandidate latent ŷ′ ← ŷ_(k) + p 6:    get decoder prediction {circumflexover (x)}' ← D(ŷ′) 7:    evaluate

 (x, ŷ′, {circumflex over (x)}′ ) 8:    if

 (x, ŷ′, {circumflex over (x)}′ ) satisfies improvement criteria then 9:      set ŷ_(k+1) ← ŷ′ 10:       k ← k + 1 11:    end if 12: end while13: Output:    finetuned latent ŷ_(k)

The general procedure is outlined in Algorithm 14.2. At each iteration,the perturbation is sampled from a probability distribution P, definedover the space of integer-valued vectors.

A new candidate latent ŷ′=ŷ+p is set. Then, this candidate is checked tosee if it improves the latent finetuning loss in some way. If it does,then the candidate latent is accepted as the new latent. The loop beginsanew, until a stopping criteria is reached.

There are several variants to this algorithm:

-   -   the probability distribution P could depend on        -   the iteration count k        -   the current latent ŷ. For example, the likelihood of a            latent pixel being perturbed could be correlated with the            size of the latent pixel.        -   the current finetuning loss, including the gradient of the            finetuning loss. For example the likelihood of a latent            pixel being perturbed could be linked to the size of the            gradient at that pixel.        -   the input image or the predicted image    -   similarly the improvement criteria, used to determine whether or        not to accept the candidate latent is acceptable, could        -   depend on the current iteration count k (for example, as is            done in Simulated Annealing)        -   only accept candidates if the finetuning loss improves (as            in a greedy approach)        -   accept non-improving perturbations with some probability (as            in Metropolis-Hastings and simulated annealing)

Parallelization and the Receptive Field

The latent perturbation can be chosen to only affect a small portion ofthe latent vector. At the extreme end, the perturbation could be appliedto only one pixel (element) in the latent vector. In this scenario, itmay not be necessary to run the entire perturbed latent ŷ k through thedecoder network (to check the prediction {circumflex over (x)}_(k)'squality). Instead, only a small portion of the latent may be needed: allthose pixels adjacent to the perturbed pixel, in the receptive field ofthe perturbed pixel. The receptive field of the perturbed pixel are alllatent pixels needed to compute prediction pixels that are influenced bythe perturbed latent pixel.

When only a small portion of latents are needed each iteration, theentire finetuning process can be parallelized. That is, on eachiteration a “batch” of many small subsets of the latent vector areprocessed in parallel. For example, in Algorithm 14.2, at eachiteration, a batch of single pixel perturbations could be generated inparallel. Each of these perturbations may then be tested to see if theyimprove the finetuning loss (where only the local receptive field ischecked, for every single-pixel perturbation in the batch). Only thosesingle-pixel perturbations that improve the loss are accepted, and areused to update the latent.

Latent Perturbations as a Gaussian Process

The latent perturbations may be modeled as a Gaussian process. In thisscenario, the perturbation itself is modeled as a parameter, to belearned as a Gaussian process. The perturbation is assumed to follow amultivariate Normal distribution. The Gaussian process modelling theperturbation is learned by updating the kernel function of the Gaussianprocess.

This is similar to interpreting the perturbation as hyperparameters froma given set, and learning these hyperparameters with a Gaussian Process.This can be viewed as an image-specific, natural extension of learningother hyperparameters, e.g. the learning-rate and/or the weight-decay,with Gaussian Processes. The details of how to execute this “smart”hyperparameter search using GP is common industry knowledge. Note, thatfor scalability we need overlapping GPs, Mixture-of-Experts (MoE) GPs orother modern techniques to make the computations feasible in practice.

Sparsity Inducing Methods: Hard Thresholding and Iterative Shrinkage

In a compression pipeline, latent values that are zero are extremelyeasy to compress, and come with almost no bit cost. Therefore, it may bedesirable to encourage the latent vector to be as sparse as possible (Avector is sparse when it is made mostly of entries with value zero).

Thus, sparsity inducing methods may be used on the latent vector. Forexample, the following optimization problem may be solved

$\begin{matrix}{{\min\limits_{\hat{y}}{{dist}\left( {x,{D\left( \overset{\hat{}}{y} \right)}} \right)}} + {\overset{\hat{}}{y}}_{0}} & (14.8)\end{matrix}$

where ∥ŷ∥₀ is the l₀ counting “norm”, which counts the number ofnon-zero elements in ŷ.

Several optimization strategies can be used to tackle this problem. Forinstance, hard thresholding may be used; FIG. 108 shows an example plotof the hard thresholding and shrinkage functions, with s=1. Define thethresholding operator

${\mathcal{H}_{s}(y)} = \left\{ \begin{matrix}y & {{{if}{❘y❘}} > s} \\0 & {otherwise}\end{matrix} \right.$

This function zeros any values that have magnitude less than s, butleaves all others untouched. Then an example of a hard-thresholdingupdate rule is to set ŷ_(k+1)=

(ŷ_(k)+E(x)−E(D(ŷ_(k)))). Effectively, this update rule pushes thelatents towards sparsity while still keeping distortion of theprediction small.

Another strategy is to relax the counting norm to the

₁ norm, ∥y∥₁=Σ|y_(i)|, so that the sparsity inducing optimizationproblem is

$\begin{matrix}{{\min\limits_{\hat{y}}{{dist}\left( {x,{D\left( \overset{\hat{}}{y} \right)}} \right)}} + {\overset{\hat{}}{y}}_{1}} & (14.9)\end{matrix}$

A method of tackling this problem is via iterative shrinkage. Define theshrinkage operator

${\mathcal{T}_{s}(y)} = \left\{ \begin{matrix}{y - s} & {{{if}y} > s} \\{y + s} & {{{if}y} < {- s}} \\0 & {otherwise}\end{matrix} \right.$

An iterative shrinkage update rule would set ŷ_(k+1)=

(ŷ_(k)+E(x)−E(D(ŷ_(k)))). This too has the effect of sparsifying thelatent space, while still maintaining minimal distortion.

Reinforcement Learning Approaches

The problem of latent finetuning can also be cast as one ofReinforcement Learning. In this setting, the construction of the latentperturbation is tasked to an agent, which for example could be anotherneural network. In a Reinforcement Learning setting, the agent takes anaction, which in our setting is the choice of perturbation. If theperturbation chosen by the agent improves the finetuning loss, the agentreceives a reward. If, on the other hand, the agent worsens thefinetuning loss, the agent receives a penalty. The agent's goal is tomaximize its rewards (and minimize its penalties). A ReinforcementLearning algorithm is used to train the agent to make good actions (goodlatent perturbations).

Once the agent has been trained, it can be deployed into an AI-basedcompression pipeline to finetune the latent variable. So for example inAlgorithm 14.1, the agent will be responsible for updating the latentŷ_(k) with a choice of perturbation p. Note that the reinforcementlearning algorithm could also be used to update any of the “pull-back”variables, such as y or x, parameterizing ŷ.

14.2.4 Relation to Adversarial Attacks

Latent finetuning shares many similarities with the Deep Learningsubfield of adversarial attacks. Research has shown that neural networkscan be extremely sensitive to tiny perturbations to their input (forexample, an input image; or in our case, the latent vector). In thesubfield of adversarial attacks, perturbations are created to break thenetwork in some way. For example, if the network's job is to classify animage (say, as a cat or a dog), then an adversarial attack could be atiny perturbation, imperceptible to the human eye, that causes thenetwork to mis-classify the input image. It turns out that creatingthese types of adversarial perturbations is often surprisingly easy.

Most often, the route to creating an adversarial perturbation is (as iscommon in machine learning) through a loss function. The loss functionmeasures the performance of the neural network (smaller loss valuesmeaning that the network is performing well). In adversarialattack—unlike in latent finetuning—the perturbation must make theperformance of the network worse. Therefore, perturbations are createdwhich maximize the loss. Typically, there will also be a constraintkeeping the perturbation imperceptible to the human eye.

Thus, there are many similarities between adversarial attacks and latentfinetuning. Whereas an adversarial attack seeks to maximize a loss,latent finetuning seeks to minimize a performance loss. Both howeverattempt to keep perturbations minimal in some way, so that theperturbations effect is not (or barely) visible to the human eye.

Therefore, any adversarial attack method can be used for latentfinetuning, simply by using a finetuning loss that should be minimized(rather than maximized). In a certain sense, latent finetuning is a kindof “reverse adversarial attack”, or a “friendly attack”.

Examples of adversarial attacks that can be used for latent finetuninginclude

-   -   Projected Gradient Descent (& Proximal Gradient). These        algorithms minimize the performance loss subject to a constraint        that perturbations do not grow larger than a threshold size.    -   Fast Gradient Sign Method. These algorithms calculate the        perturbation p from the sign of the loss gradient.    -   Carlini-Wagner type attacks. These algorithms minimize        perturbation size subject to a requirement that the performance        loss below some threshold.    -   Backward Pass Differentiable Approximation. These algorithms        approximate the gradients of non-smooth functions (such as the        quantization function) with another function.

14.3 Innovation: Functional Finetuning

The behaviour of the decoder D, which takes the latent variable ŷ andoutputs a prediction {circumflex over (x)}, is controlled by theparameters of the decoder's neural network. These parameters include:

-   -   The matrices of each linear function in the decoder. These are        sometimes called weight matrices. In a convolutional neural        network, these are the kernel weights of the convolutional        kernel. For example, in one layer of a convolutional neural        network, the output of a layer may be given as y=K*x+b. Here K        is a convolutional kernel, and b is a bias vector. Both K and b        are parameters of this layer.    -   The activation functions (non-linearities) of the neural network        may be parameterized in some way. For example a PReLU activation        function has the form

PReLU(x)=max{αx,x}

The parameter α could act on a particular channel; could be a singlescalar; or could act on a per-element basis.

-   -   The quantization function may be parameterized by the ‘bin size’        of the quantization function. For example, let round(x) be the        function that rounds real numbers to the nearest integer. Then        the quantization function Q may be given as

${Q(y)} = {\delta{round}\left( \frac{y}{\delta} \right)}$

The parameter δ controls the bin size of the rounding function. Theparameter δ could act on a particular channel of y; could be a singlescalar; or could act on a per-element basis.

After a compression pipeline has been trained, in a standard pipelineall of the parameters (denoted θ) of the decoder are fixed andimmutable. The innovation of functional finetuning is that in fact, someor all of the parameters of the decoder may be modified on a per-inputbasis. That is, a functional finetuning unit (see FIG. 109 for example)may calculate some additional parameters ϕ. These additional parametersmay modify the original parameters θ in some way, or could parameterizeaspects of the decoder (such as the weight matrices, the activationfunctions, or the bin size). These additional parameters are able topowerfully modify the behaviour of the decoding function, and can offerimpressive performance gains.

Of course, since the additional parameters ϕ are calculated on aper-input basis, and so they must be encoded in the bitstream in someway, as meta-information in the bitstream. Thus, the additionalparameters ϕ come with the cost of additional bits. However it is hopedthat the extra information needed to represent ϕ is compensated byimprovements to the bitstream length of ŷ and/or with a reduction indistortion between x and {circumflex over (x)}.

The additional parameters ϕ may be encoded in the bitstream in one ofseveral ways.

-   -   The additional parameter ϕ may be the output of an additional        hyper-prior network (see FIG. 110 for example). In this setup,        an integer valued hyper-parameter {circumflex over (z)} is        encoded to the bitstream using an arithmetic encoder/decoder,        and a probability model on {circumflex over (z)}. In other        words, ϕ is itself parameterized by {circumflex over (z)}. The        hyper-parameter {circumflex over (z)} could be chosen in several        ways:        -   Given an input x and latent ŷ, the variable {circumflex over            (z)} can be chosen on a per-input basis, so as to minimize            the standard rate-distortion trade-off (since the bitstream            length of {circumflex over (z)} can be estimated with the            probability model on {circumflex over (z)}).        -   Given a latent ŷ, the variable {circumflex over (z)} could            be defined as {circumflex over (z)}=Q(HE(ŷ)), where HE is a            ‘hyper-encoder’, i.e. another neural network.    -   The additional parameter ϕ may be the output of a context model.        A context model is any model that uses previously decoded        information (say, {circumflex over (x)} or ŷ). For example, if        an image is decoded in a pixel-by-pixel fashion, a context model        takes in all previously decoded pixels. An autoregressive model        is an example of a context model.    -   The additional parameter ϕ could be encoded with a lossless        encoder. This includes for example run-length encoding.

Other ways to use the additional parameter in the decoder include:

-   -   The additional parameters could be a discrete perturbation of        the decoder weights θ. That is, the decoder could take as        weights θ+{circumflex over (ϕ)}, where {circumflex over (ϕ)}        belongs to some discrete set of perturbations. A lossless        encoding scheme would be used to encode symbols from this        discrete set of perturbations.    -   The general parameters θ could be modified by a perturbation p,        where the perturbation is parameterized by ϕ. So for example the        decoder could take as weights θ+p(ϕ). This perturbation could be        modeled by a low dimensional parameterization, such as a normal        distribution, or any other low-dimensional approximation. For        instance, the weight kernels of a convolutional network could be        perturbed on a channel-by-channel basis by a parametric function        of ϕ.    -   The additional parameters could multiply the decoder weights θ.        This could be on a per-channel basis, or a per-layer basis (or        both per-channel and per-layer). distribution

An illustration of how ϕ could be used is the following. Suppose ϕ couldbe drawn from a finite set, so that it can be encoded using a losslessencoder. Then, for a given ŷ (the quantized latent produced from x bythe encoder), ϕ could be chosen to minimize the rate-distortiontrade-off (where now rate measures the additional bitstream length ofencoding ϕ):

$\begin{matrix}{{\min\limits_{\phi}{R(\phi)}} + {{dist}\left( {x,{D\left( {{\overset{\hat{}}{y};\theta},\phi} \right)}} \right)}} & (14.1)\end{matrix}$

Here R(ϕ) is the rate (bitsteam length) of ϕ, and {circumflex over(x)}=D(ŷ; θ, ϕ) is the output of the decoder. In this example thedecoder is parameterized by both the general parameters θ (fixed afterthe compression pipeline has been trained), and ϕ (which are chosen on aper-input basis according to the optimization procedure).

Note that finetuning the decoder D (this section) and finetuning thelatents (Section 14.2), are not mutually exclusive procedures, and cancomplement each other.

14.4 Innovation: Finetuning the Network Path

A convolutional neural network is made up of a series of convolutionaloperations, and activation functions. Let's let the input to one ofthese convolutional operations be a tensor of shape C_(in)×H×W. Given aninput x and a convolutional kernel K with C_(in) input channels, andC_(out) output channels, the convolutional operation can be written as

$\begin{matrix}{y_{j} = {\sum\limits_{i = 1}^{C_{in}}{K_{ji}*x_{i}}}} & (14.11)\end{matrix}$

That is, the j-th output channel is the sum of convolutions over theinput channels. This can be viewed as a fully-connected network over theinput channels: the output of each layer depends on all previouschannels. See for example FIG. 111 .

The idea of this section is to sparsify the convolutional kernels ofeach layer, on a per-input basis (to sparsify means to render an objectsparse, in that it has few non-zero elements). This means that, given afixed input to the neural network, many of the channel weights will beinactivated, and not used in the computation. This can be done forexample with a binary mask M, where M has shape C_(out)×C_(in). I.e.m_(ij)∈{0, 1}. Then,

$\begin{matrix}{y_{j} = {\sum\limits_{i = 1}^{C_{in}}{\left( {m_{ij}K_{ji}} \right)*x_{i}}}} & (14.12)\end{matrix}$

If the mask has many zero elements, this can massively reduce the numberof computations needed in each layer, for only channels with non-zeromasks will be used in the computation. This is illustrated for examplein FIG. 112 .

Importantly, the mask can be optimized on a per-input basis. Forexample, the mask can be chosen to improve the rate-distortion loss ofthe input. The optimization of the mask can be done in several ways:

-   -   Ranking-based mask Each connection (input-output pair) in each        layer is assigned a score. The score is mapped to the interval        [0, 1]. During optimization, the scores for each layer are        chosen to minimize a loss, such as the rate-distortion trade-off        of the input. Then, only those scores with a cutoff above a        certain threshold are used. The mask used at decode time is the        binarized scores (1 for those scores above the threshold; 0 for        those below the threshold).    -   Stochastic mask At the beginning of optimization, connections        are sampled randomly as Bernoulli trials from {0, 1}, with equal        probability. However, as training progresses, connections that        appear to improve the performance of the network become more        likely to be activated (set to 1.). Connections that harm the        network, or appear not to be useful, become more likely to be        deactivated (set to 0).    -   Sparsity regularization The mask values may be penalized by a        sparsity regularization term, such as the        ₁ norm of the mask values, encouraging sparsity of the mask        weights. Updates to the mask weights may be done using proximal        update rules, including hard thresholding or iterative        shrinkage.

The binary mask must be transmitted in the bitstream. The binary maskcan be encoded with any lossless encoder.

Note that choosing the optimal mask is itself a non-linear operation.Therefore, it may be possible to use a decoder D without any othernon-linear activation functions. Once the mask has been chosen, themasked decoder network is a series of linear transformations, which maymassively speed up decode time.

14.5 Concepts

-   -   1. The innovation of post-processing image/video-specific        finetuning for the AI-based compression pipeline. In this        context, finetuning includes: Latent finetuning, Functional        Finetuning and Path Finetuning. See Sections 14.2, 14.3, 14.4.    -   2. The innovation of post-processing image/video-specific        finetuning for the AI-based compression pipeline using the        method: Gradient descent and other 1st order approximation        methods. See 14.2.3.    -   3. The innovation of post-processing image/video-specific        finetuning for the AI-based compression pipeline using the        method: 2nd order approximation methods. See 14.2.3.    -   4. The technique of receptive field methods and        finetune-batching to make the finetuning algorithms        significantly faster. This approach is not restricted to the        finetuning method and works with most approaches. See 14.2.3.    -   5. Post-processing image/video-specific finetuning for the        AI-based compression pipeline using the method: Gaussian        Processes. See 14.2.3.    -   6. Post-processing image/video-specific finetuning for the        AI-based compression pipeline using the method: Hard        Thresholding and Iterative Shrinkage Processes. See 14.2.3.    -   7. Post-processing image/video-specific finetuning for the        AI-based compression pipeline using Reinforcement Learning        methods. See 14.2.3.    -   8. Finetuning anything in the AI-based Compression pipeline as a        reverse adversarial attack. Thus, all literature and methods        from this domain may apply to us. See 14.2.4.    -   9. Post-processing image/video-specific finetuning for the        AI-based compression pipeline using metainformation through        different approaches. See 14.3.    -   10. Post-processing image/video-specific finetuning for the        AI-based compression pipeline using path-specific data through        different approaches. See 14.4.

15. KNet—Conditional Linear Neural Network Decoder 15.1 Introduction

The current media compression advances of state-of-the-art AI-basedimage and video compression pipelines are still severely limited by thecomputational demand of these algorithms. Practical use of bettercompression methods requires these approaches to run in real-time,defined as at least 25 frames per second decoding time. Up until thispoint, there are no learned image and video compression pipelinescapable of this feat. In fact, current AI-based compression approachesare at least 1,000×too slow and computational-heavy to run in real-time[3]. Here novel methods of offloading decoding cost to the encodingphase for a learned image and video compression pipeline are presented.Our innovation uses metadata to transform the conditioned decoder into alinear function to realise real-time decoding times for high-resolutiondata. These methods may be collectively referred to as KNet.

Lossless data compression is about minimising the amount of informationrequired to explain the data. The data could be an image, video,VR-data, AR-data, satellite data, medical data, text et cetera, so longas it can be represented in some latent, compressed form, that holds thesame amount of information as the original data. Lossy compression isthe same as lossless compression without the requirement to recreate theoriginal data perfectly but allowed to have some distortion in theoutput. Our described innovation can be applied to lossy and losslesscompression.

Compression algorithms have an encoding part which compresses the data,and a decoding part which decompresses the compressed data into theoriginal data (with some distortion). Compression codecs arewell-researched and standardised compression algorithms.

We call all compression codecs that do not utilise neural networks“traditional compression” approaches. The vast majority of all codecs,and all commercially available codecs, are from the traditionalcompression approach. In the past three years, there is a new class ofcompression algorithms being researched. These new algorithms are basedaround neural networks, have entirely different properties compared tothe traditional approaches, and we call them “AI-based compression”methods.

15.1.1 the Importance of Decoding Runtime

Recently, AI-based image and video compression has shown tremendouspromise and is already at a maturity level to outperformtraditional-based image and video compression methods such as JPEG,JPEG2000, WEBP, BPG, HEIC, HEIF, H.264, H.265, AV1, H.266 [4].

A remaining challenge to transition this technology from “research” intoan application is the issue of runtime. An image and video compressioncodec that cannot run in real-time is not a viable product. Especiallynoteworthy is the decoding time; users expect to see content, e.g.movies, with 25/30/60/90 frames-per-second (fps). Thus, the decodingtime of a compression algorithm must be under 40/33.3/16.6/11.1milliseconds per frame, respectively, to satisfy the demand of the user.

Note that the algorithm's runtime and the decoding runtime are relatedbut not the same properties. The codec's overall runtime is the encodingtime plus the decoding time. The encoding time is measured as the timeit takes to compress raw content into the compressed bitstream. Thedecoding time is measured as the time it takes to decompress thebitstream into the final output content. FIG. 113 illustrates an exampleof this concept.

In the vast majority of the use cases for image and video data, decodingtime is significantly more important than encoding time. This asymmetryis reflected by the asymmetric encoding-decoding process of traditionalimage and video compression approaches. Algorithms such as WebP, HEIC,HEIF, HEVC, AV1 and others, have 100×-1000×runtime differences betweenencoding and decoding, with decoding being quick and encoding beingslow. For instance, for the use case of video-on-demand, Netflix states[5] that a 100× complexity increase in encoding would be acceptablewithout causing any problems, given that it is accompanied by bettercompression performance with adequate transmission time of the data toall end users.

The current state-of-the-art neural networks used in AI-basedcompression approaches do not utilise this asymmetry property and aremostly symmetric. Thus, the state-of-the-art of AI-based compressionapproaches have similar decoding and encoding times, both of which are,in most cases, too slow to be marketable.

15.1.2 the Challenge of Decoding Runtime in AI-Based Compression

Every compression codec faces the challenge of balancing runtime andperformance this is especially true for AI-based compression. AI-basedcompression builds its framework around the usage of neural networks,and neural networks require immense computational efforts. To give threeexamples:

First, using the performance-optimised AI-based compression pipelinefrom [6], the runtime is 230 ms for a 768×512 image on a non-mobile CPU,with smartphone CPUs being 5×-10× slower than non-mobile CPUs.Extrapolating this data to higher-resolutions, we can find approximatedecoding time for various resolutions in the table below:

Decoding Runtime for Kodak 4K, 8K Resolutions Device Kodak (768 × 512)4K-Frame 8K Frame Non-Mobile 0.23 sec  4.90 sec 19.61 sec Mobile 1.15sec 24.50 sec 98.05 sec

Thus, the “efficient” AI-based compression pipeline is 150×(non-mobile)to 750× (mobile) times too slow to be used in practice for 4K 30 fpsvideo. And the “efficient” AI-based compression pipeline is 600×(non-mobile) to 3,000× (mobile) times too slow to be used in practicefor 8K 30 fps video.

Second, we can calculate the number of floating-point operations (FLOPs)required by the decoding neural network using the architecture describedin [4]. The decoding neural network requires 48 TFLOPs. Modernsmartphones can, at best, process up to 100 GFLOPS to 1 TFLOPs. Thus,running a 4K decoding pass with 30 fps would require 1,440 TFLOPS or1,440× the processing power of modern smartphones, assuming 100% of thetheoretical FLOP-capacity can be used.

Finally, we can look at the decoding times of different AI-based imagecompression approaches of the CLIC challenge [7]. The leaderboard of theCLIC challenge 2020 shows the average decoding times of differentcompression approaches over the CLIC Validation image dataset,consisting of 102 mobile and professional photos of varying resolutions,ranging from 384 to 2048 pixels per dimension. While BPG, a traditionalcompression approach, requires 696 ms, the AI-based approaches requireon average roughly 100s (some algorithms up to 300s) per image. Thus,the AI-based methods are 150×-450× times slower than the traditionalapproaches. This comparison would be even worse for practical use cases,as the BPG algorithm was executed on a CPU, whilst the AI-basedalgorithms were executed on computationally-powerful GPU platforms. Inpractice, GPUs are rarely available, and CPUs are up to 10×-100× slowerthan GPUs for neural network executions.

In short, current AI-based compression pipelines can not be run inreal-time. In fact, decoding times are multiple orders of magnitude tooslow for even 30 fps-streaming. We need radical change to make it work.

15.2 Background Knowledge 15.2.1 Linear and Nonlinear Functions

A linear function is a function ƒ(x) for which Properties 15.1 and 15.2below hold:

ƒ(a+b)=ƒ(a)+ƒ(b)(15.1)

ƒ(λ·a)=λ·ƒ(a)(15.2)

We can represent any linear function as a matrix multiplication and anaddition. For an input x ∈

^(N×1), a weight matrix W ∈

^(M×N), a bias b ∈

^(M×1), and [·] being the standard matrix-vector multiplicationoperator, a generalised formulation of linear functions is thus:

ƒ(x)=W·x+b(15.3)

A striking property of linear functions is that the function-wisecomposition of two, or multiple, linear functions remains a linearfunction. For instance:

ƒ(x) is linear,g(x) is linear→h(x)=g(ƒ(x))=(g∘ƒ)(x) is linear  (15.4)

Mathematically, with the above-mentioned matrix-bias-vector notation,this is easy to prove. Let x be the input, W_(ƒ) and b_(ƒ) be theparameters for the first generalised linear function ƒ(·), and W_(g) andb_(g) be the parameters for the second generalised linear function g(·).Then, the function composition (g∘ƒ)(·)=h(·) can be written as

$\begin{matrix}\begin{matrix}{\left( {g \circ f} \right)(x)} & {= {{W_{g} \cdot \left( {{W_{f} \cdot x} + b_{f}} \right)} + b_{g}}} \\ & {= {{W_{g} \cdot W_{f} \cdot x} + {W_{g} \cdot b_{f}} + b_{g}}} \\ & {= {{\left( {W_{g} \cdot W_{f}} \right) \cdot x} + \left( {{W_{g} \cdot b_{f}} + b_{g}} \right)}} \\ & {= {{W_{h} \cdot x} + b_{h}}} \\ & {= {h(x)}}\end{matrix} & (15.5)\end{matrix}$

where the function-wise composition of the two linear functions ƒ and ggive rise to a new linear function h with parameters W_(h) and b_(h).

Nonlinear functions are all functions for which either of the Properties15.1 or 15.2 do not hold. Nonlinear functions have significantly higherexpressive power and modelling capabilities than linear functions. For aconceptual intuition, linear functions are only able to representstraight lines, whereas nonlinear functions can also represent curves,something which is much more difficult for linear functions. Therefore,a nonlinear function has much more modelling flexibility than a linearone.

For example, in FIG. 114 , a linear function can be expressed as toeasily separate the two different classes of data points in the leftplot. However, it will be more difficult to perform the same task in theright plot, whereby a nonlinear function would be more capable for thisproblem.

15.2.2 Nonlinearities within Neural Networks

A neural network is conventionally comprised of alternating linear andnonlinear operations cascaded iteratively. Most neural networks arebased around the repeating structure:

As illustrated for example in FIG. 115 , chaining together multiple ofthese operations is the backbone of every modern neural network.

Please note that there are numerous ways of expressing n-dimensionalconvolution operations. We can either use the convolution symbol [

], or instead, flatten the input and use the matrix-vector product. Bothexpression are equivalent; after all, a convolution is a linearfunction, and thus, can be written in the generalised linear functionformat mentioned earlier.

$\begin{matrix}{{{input}x} \in {\mathbb{R}}^{N \times M}} & (15.6)\end{matrix}$ convolutionkernel ∈ ℝ^(U × V) x_(flat) ∈ ℝ^((N ⋅ M) × 1)$W_{k} = {k_{reshaped} \in {\mathbb{R}}^{{({{\lfloor{N - \frac{U}{2}}\rfloor} \cdot {\lfloor{M - \frac{V}{2}}\rfloor}})} \times {({N \cdot M})}}}$f(x) = kx ⇔ f(x) = W_(k) ⋅ x_(flat)

In neural network semantics, a nonlinearity is interchangeable with theterm activation function, which inherits its name based on the idea ofthe action potential firing within biological neurons. Typical nonlinearactivation functions include sigmoid, Tanh, ReLU and PreLU. Training aneural network can be seen as fitting a nonlinear function to inputdata.

It is essential to understand the significance behind nonlinearitiesinside a neural network. The nonlinear operations that follow theconvolution and bias operations are the reason for the nonlinearity ofthe entire network and are the reason for the expressive power of neuralnetworks. It is commonly accepted that the more nonlinear a neuralnetwork is, the better its problem modelling capacity. Even further, theentire proof of neural networks being universal function approximatorsrelies on the nonlinearity, and the proof does not work without theseoperations [8][9].

In short, nonlinearities are an essential part of neural networks, andcannot be removed without significant penalties to the network'sexpressive power.

Mathematically, we can write a neural network with N repeatedconvolution-bias-activation structures as:

ƒ_(N)(W _(N)·ƒ_(N−1)(W _(N−1)·( . . . ƒ₁(W ₁ ·×+b ₁))+b _(N−1))+b_(N))  (15.7)

With ƒ_(i)(·) being the ith layer nonlinearity, W_(i) representing theith layer convolution and b_(i) representing the ith layer bias.

15.2.3 Purely Linear Neural Networks

Let us now assume that we would remove the nonlinear operations from aneural network. Then the typical neural network chain would devolve to asequence of purely linear operations:

Mathematically, we end up with a composition of linear functions. Owingto (15.5), we can thus write the entire network as one single linearfunction:

Proof:

ƒ(x)=ƒ_(N)(W _(N)·(ƒ_(N−1)(W _(N−1). . . (ƒ₁(W ₁ ·x)+b ₁))+b _(N−1))+b_(N))

⬇

Remove nonlinear functions ƒ_(N)(·)

⬇

=W _(N)·(W _(N−1) ·x+b _(N−1))+b _(N)

=(W _(N) ·W _(N−1))·x+(W _(N) ·b _(N−1) +b _(N))

=W _(new) ·x+b _(new)  (15.8)

Thus, a purely linear N-layer neural network is equivalent to a 1-layerneural network. Mathematically, such a network is equivalent to usingmultivariate linear regression. Since this neural network has demoted toa purely linear function, it loses expressive power. However, thanks tothe ability to squash a chain of linear functions into one linearcomposition function, the number of operations necessary to perform aforward pass has been reduced dramatically. As a result, the network cangain significantly in runtime performance, since a linear single-layernetwork can be executed much faster, and with substantially less memoryfootprint (memory access time) than an N-layer network. In essence,choosing the network complexity induces an implicit trade-off betweenpredictive performance and runtime. We visualise this trade-off in FIG.116 by example.

Nonlinear Neural Network:conv→bias→nonlinearity→conv→bias→non-linearity→. . .

Linear Neural Network: conv→bias→conv→bias→conv→bias→. . .

15.3 an Innovation 15.3.1 A Novel Class of Nonlinearities

The current state-of-the-art in neural network architecture design is touse element-wise nonlinearities. In other words, every element in aninput tensor is activated independently from one and another, and onlydepends on its current value as it is passed into the activationfunction. FIG. 117 showcases some of the most popular non-linearities.

Instead of thinking of an element-wise nonlinearity as a function,alternatively, we can think of it as an element-wise multiplication witha tensor that is dependent on its input. For instance, without loss ofgenerality, the ReLU function in Equation (15.9) can be thought of as anelement-wise multiplication between the input x and a mask R, consistingof is and 0s, that has been conditioned on the input x (15.10). Thus,ReLU can be restated as (15.11), where ⊙ is the element-wisemultiplication operation.

$\begin{matrix}{{{ReLU}(x)} = \left\{ \begin{matrix}{x,} & {{{if}x} > 0} \\{0,} & {otherwise}\end{matrix} \right.} & (15.9)\end{matrix}$ $\begin{matrix}{\left. {{ReLU}(x)}\Leftrightarrow{x \odot {R(x)}} \right.,{R \in \left\{ {0,1} \right\}^{N \times M}},{x \in {\mathbb{R}}^{N \times M}}} & (15.1)\end{matrix}$ $\begin{matrix}{{{ReLU}(x)} = {x \odot {R(x)}}} & (15.11)\end{matrix}$

With this interpretation of activation functions, our innovation is toreplace the element-wise nonlinearity with a convolution operation whoseparameters have been conditioned on its inputs. The values attained bythe parameters of these convolutions, comprised by a convolution kernel,are dependent on the input with the dependency being fully described bya nonlinear function.

Let's assume we have a neural network with two convolutional layersrepresented by W₁ and W₂. We will ignore the bias without loss ofgenerality. The exact definitions of the kernel weights of W₁ and W₂determine whether the neural network is a linear function or a nonlinearfunction. If W₁ and W₂ are both operations with fixed convolutionkernel, e.g. the kernel weights are constant across all input, thenetwork is linear. However, if one of the operations, let's say W₂(·)without loss of generality, is dependent on the input, the situationchanges. If the function determining the weights of W₂, namely W₂(·), isnonlinear, then the neural network is nonlinear. If not, then thenetwork is linear.

W ₂ ·W ₁ ·x is linear⇔If W ₂and W ₁ are constant

W ₂(W ₁ ·x)·W ₁ ·x is linear⇔Only if W ₂(W ₁ ·x) is linear

W ₂(W ₁ ·x)·W ₁ ·x is non linear⇔Only if W ₂(W ₁ ·x) is nonlinear  (15.12)

Chaining multiple layers of a neural network together with the novelconvolution nonlinearity, and ignoring the bias for simplicity andwithout loss of generality, we get:

$\begin{matrix}{{f(x)} = {{W_{N}\left( {input}_{N - 1} \right)} \cdot W_{N} \cdot {W_{N - 1}\left( {input}_{N - 2} \right)} \cdot W_{N - 1} \cdot \ldots \cdot x}} & (15.13)\end{matrix}$ input₀ = x input₁ = W₁ ⋅ x input₂ = W₂(input₁) ⋅ W₁ ⋅ x ⋮input_(M) = W_(M)(input_(M − 1)) ⋅ W_(M) ⋅ W_(M − 1)(input_(M − 2)) ⋅ W_(M − 1) ⋅ … ⋅ x

This chaining procedure can be termed kernel composition, since theresulting kernel from the sequential convolution kernels is a compositeconvolution kernel encapsulating all of its constituent kernels. Thealgorithm of this procedure can be seen in Section 15.3.4 and an examplevisualisation can be seen under Section 15.5 in FIG. 119 .

15.3.2 a Meta-Information Conditioned Decoder

The mathematical structure of the proposed nonlinearities can beexpressed as a linear function (such as a convolution operation), whilstthe values they attain have originated as a result of nonlineartransformations on the input.

With the above-described innovation, the nonlinear convolutionoperation, what do we win? It is crucial to note that the entire neuralnetwork, composed of convolutions, nonlinear convolutions and biasesremains a nonlinear function, with high predictive power but slowruntime.

However, if we condition the neural network on the convolution-kernelsof the nonlinear convolution, we end up with a linear network, with thepower of a nonlinear network.

The entire network(encoder and decoder)network⇔is a nonlinear function

The encoder network⇔is a nonlinear function

The decoder network⇔is a nonlinear function

The decoder network conditioned on meta-information⇔is a linearfunction(15.14)

Mathematically, this is easy to see, as the conditioning simply crossesout the input-dependencies:

$\begin{matrix}{\left. {{\overset{{nonlinear}{conv}}{\overset{︷}{W_{N}^{NL}\left( {input}_{N - 1} \right)}} \cdot W_{N - 1} \cdot W_{N - 1}^{NL}}{\left( {input}_{N - 2} \right) \cdot \overset{\overset{normal}{conv}}{\overset{︷}{W_{N - 2}}} \cdot \ldots \cdot x}} \right\}{}\begin{matrix}{Nonlinear} \\{function}\end{matrix}} \\\left. \downarrow{Conditioning} \right. \\{\left. {\overset{\overset{Conditioned}{conv}}{\overset{︷}{W_{N}^{NL}}}\  \cdot W_{N - 1} \cdot W_{N - 1}^{NL} \cdot W_{N - 2} \cdot \ldots \cdot x} \right\}\begin{matrix}{Linear} \\{function}\end{matrix}}\end{matrix}$

The innovation is to use nonlinear convolution in the Decoder of theAI-based compression pipeline. During the encoding path, the userpredicts the nonlinear convolution kernels. Additional to the compressedbitstream, the encoding-user sends these kernels as meta-information tothe receiving user. The receiving user uses the additional metainformation and conditions the decoding network on that information,resulting in, from his point-of-view, a purely linear neural network.

Thus, we can combine the predictive power of nonlinear neural networks,with the runtime benefits of purely linear neural network—All at thecost of some additional meta-information. FIG. 118 conceptualises theinnovation, in an example.

15.3.3 Notes on the Generalisation

We use nonlinear convolutions as an operation that is nonlinear if it isunconditioned, but which becomes linear once it is conditioned onappropriate metainformation.

We use the nonlinear convolution as an example for numerous potentialclasses of operations with this property, as it showed the bestperformance in our tests. However, the innovation comprises all classesof operations with these properties and not merely nonlinearconvolutions. For instance, the innovation of conditioned lineardecoders will also hold true if we replace the nonlinear convolutionswith nonlinear element-wise matrix multiplication; or nonlinear matrixmultiplication; or a nonlinear addition operation. The innovation isabout the conditioning the make a nonlinear function linear in thecontext of neural networks; not about the exact way we use doing it.

Let's assume we have a function space

which we can describe as the union of two disjoint sub-spaces

_(L) and

_(NL)·

_(L) being the set of linear functions in

,

_(NL) being the set of nonlinear functions in

.

=

_(L)

_(NL)

_(L)

_(NL)=θ  (15.15)

Functions in TL have fast execution time but limited expressiveness,whereas functions in

_(NL) have slow execution time but strong expressiveness. Our innovationproposes an efficient way of finding a function ƒ in

which is in the set

_(NL), but which is part of the set

_(NL) when conditioned on additional meta information m.

ƒ∈

and ƒ|m∈

  (15.16)

15.3.4 Algorithms

Table 15.1 and Table 15.2 show an example layout of the networkarchitectures used during training and inference of KNet.

TABLE 15.1 Training refers to the layers used by the KNet component inthe decoder shown in Table 15.2 during network training. WhereasInference refers to the layers or operations used during inference. Amore generic algorithm of the KNet training procedure is shown inAlgorithm 15.1. Kernel Composition is described by Algorithm 15.2. KNetExample Training Inference Conv 7 × 7 c192 Kernel Composition KNetActivation Kernel Conv 27 × 27 c3 KNet Conv 3 × 3 c192 KNet ActivationKernel KNet Conv 3 × 3 c192 KNet Activation Kernel KNet Conv 5 × 5 c3

TABLE 15.2 For each module of the proposed network, each row indicatesthe type of layer in a sequential order. See table 15.1 for thedefinition of KNet. Encoder Decoder Hyper Encoder Hyper Decoder KNetEncoder KNet Decoder Conv 5 × 5 c192 Upsample ×4 Conv 3 × 3 c192 Conv 3× 3 c192 Conv 3 × 3 c192 Conv 3 × 3 c576 PAU PReLU PReLU PReLU PReLUConv 3 × 3 c192/s2 KNet Conv 3 × 3 c192/s2 Upsample ×2 AdaptiveAvgPoolConv 3 × 3 c576/s2 PAU PReLU Conv 3 × 3 c192 Conv 3 × 3 c384 PReLU Conv3 × 3 c192/s2 Conv 3 × 3 c192/s2 PReLU PReLU Conv 3 × 3 c192 PAU PReLUUpsample ×2 AdaptiveAvgPool Conv 5 × 5 c12 Conv 3 × 3 c12 Conv 3 × 3c192 Conv 3 × 3 c576 PReLU PReLU Conv 3 × 3 c24 Adaptive Pool Conv 3 × 3c192

Algorithm 15.1 Example training forward pass for KNet Inputs: Inputtensor: x ∈

 ^(B×C×H×W) Target kernel height: kH ∈

Target kernel width: kW ∈

Result:  Activation Kernel: K ∈  

 ^(C×1×kH×kW)  Bitrate loss: R_(k) ∈  

 ⁺ Initialize:  m ← # encoder layers  n ← # decoder layers  k ← x for i← (1, . . . , m) do |  k ← Convolution_(i) (k) |   k ← Activation_(i)(k) |   k ← AdaptivePooling_(i) (k, kH, kW) end {circumflex over (k)} ←Quantize(k)  R_(k) ← EntropyCoding({circumflex over (k)}) for j ← (1, .. . ,n) do |  {circumflex over (k)} ← Convolution_(j)({circumflex over(k)}) |   {circumflex over (k)} ← Activation_(j)({circumflex over (k)})end K ← TranposeDims1_2({circumflex over (k)})

Algorithm 15.2 Kernel Composition Inputs: Decoder Weight Kernels:{W_(i)}_(i=1) ^(N) ∈

^(C) ^(out,i) ^(×C) ^(in,i) ^(×wH) ^(i) ^(×wWi) Decoder Biases:{b_(i)}_(i=1) ^(N) ∈

^(C) ^(out,i) Activation Kernels: {K_(i)}_(i=1) ^(N−1) ∈

^(C) ^(out,i) ^(×1×kH) ^(i) ^(×kW) ^(i) Result:  Composed Decoder WeightKernel: W_(d) ∈

^(3×C) ^(in,i) ^(×dH×dW)  Composed Decoder Bias: b_(d) ∈

³ Initialize: W_(d) ← W_(N) b_(d) ← b_(N) dH ← wH_(N) dW ← wW_(N) for i← (N − 1, N − 2, . . . , 1) do  | W_(d) ← Pad(W_(d), (kH_(i), kW_(i))) |  W_(d) ← DepthwiseSeparableConvolution(W_(d), Flip(K_(i)))  |  dH ←dH + kH_(i) − 1  |  dW ← dW + kW_(i) − 1  |  $\left. b_{d}\leftarrow{b_{d} + {\sum\limits_{c = 1}^{C_{{out},i}}{\sum\limits_{p = 1}^{dH}{\sum\limits_{q = 1}^{dw}{b_{i}W_{d,{({\ldots,c,p,q})}}}}}}} \right.$ |  W_(d) ← Pad(W_(d), (wH_(i), wW_(i)))  |  W_(d) ← Convolution (W_(d),Flip(TransposeDims1_2(W_(i)))) end

15.4 Facilitating KNet Module Training Regression Analysis

One of the problems with the KNet-based architecture is that it isincredibly difficult to train in an end-to-end fashion. This challengeoriginates from the KNet module requiring a stable input-distribution totrain, but the input to the KNet module is constantly changing viabackpropagation in an end-to-end setting. This section provides detailson how we can train the KNet module in a non-end-to-end fashion.

There are two ways of doing so:

-   -   1. We can start off training with a generic convolution module        as a temporary stand-in for the KNet module, which is referred        to as conv-gen. Then, possibly after convergence has been        reached, we could replace the generic convolution module with        the KNet module, freeze all the other layers in the network and        resume training. This allows the KNet module to be optimised for        separately, given the remainder of the network.    -   2. Similar to the above point, but instead of starting o        training with a generic convolution module, we can fit a        regression model given the inputted feature vector and the        target vector (the ground truth image, for example). This is        referred to as conv-reg.

For example, a linear regression analysis produces the optimal filterthat the KNet module ideally would learn, and using this optimum as aninitial proxy for our actual KNet module prediction aids the subsequenttraining process of actually optimising the KNet module with a frozenautoencoder backbone.

The challenge with the second point described immediately above is thatlinear regression only works with the assumption of no multicollinearityand assuming it processes semi-sensible inputs (ensuring stable trainingthroughout). Generally, we cannot guarantee either of these. However,there are ways that can help us in the process. For example, fortraining stability, we can start o training with both a conv-gen and aconv-reg simultaneously, operating in parallel on the same inputs andyielding two different outputs and therefore two different losscomponents,

_(gen) and

_(reg), respectively. The final loss metric

is hence a weighted sum of these two as such:

=α

_(gen)+(1−α)

_(reg)  (15.17)

Initially, the weighting factor α∈[0, 1] can be set to its maximum value(or near it), and gradually annealed towards zero. This has the effectof weighing the loss term from giving emphasis to the conv-genoperation, which is stable, to the conv-reg operation, which is closerto the desired behaviour of the KNet module.

To deal with the multicollinearity in our input space, we can useTikhonov regularisation in our regression analysis. This ensures thatthe regression calculations are stable given any arbitrary inputfeatures. Contrast an ordinary least squares approach (linear regressionanalysis) with the Tikhonov regression analysis:

W _(linear)=(Z ^(T) Z)⁻¹ Z ^(T) x  (15.18)

W _(Tikhonov)=(Z ^(T) Z+λI)⁻¹ Z ^(T) x  (15.19)

Here, Z is the design matrix (representing input features to the KNetmodule), x is the regression target (representing the target data, forexample the ground truth image) and W_(linear) and W_(Tikhonov) are theoptimal weights produced from linear regression and Tikhonov regression,respectively.

15.5 Supplementary Figures

FIGS. 119, 120 and 121 are examples which visualise import propertiesand processes of KNet.

15.6 Concepts

-   -   1. Using metainformation to transform the conditioned decoder        into a linear function to realise real-time decoding times for        high-resolution data, which may be collectively referred to as        KNet.    -   2. Substituting element-wise nonlinear functions in neural        network with linear or convolution operations whose parameters        have been conditioned on their inputs.    -   3. A chaining procedure of sequential convolution kernels into a        composite convolution kernel, for example all convolution layers        in a decoder (both unconditioned and conditioned on inputs).    -   4. Nonlinear element-wise matrix multiplication, nonlinear        matrix multiplication and nonlinear addition operation whose        parameters have been conditioned on their inputs.    -   5. Stabilising KNet module training by initial training with a        generalised convolution operation in its place, and then        freezing the autoencoder backbone and replacing the generalised        convolution operation with a KNet module that is further        optimised.    -   6. Proxy training of the KNet module with a regression        operation, either linear or Tikhonov regression or possibly        other forms.    -   7. Jointly optimising for a generalised convolution operation        and a regression operation with a weighted loss function, whose        weighting is dynamically changed over the course of network        training, and then freezing the autoencoder backbone and        replacing the generalised convolution operation and regression        operation with a KNet module that is further optimised.

15.7 References

-   [3] Sayed Omid Ayat, Mohamed Khalil-Hani, Ab Al Hadi Ab Rahman, and    Hamdan Abdellatef Rosenbaum. “Spectral-based convolutional neural    network without multiple spatial-frequency domain switchings.”    Neurocomputing, 364, pp. 152-167 (2019).-   [4] Ciro Cursio, Dimitrios Kollias, Chri Besenbruch, Arsalan Zafar,    Jan Xu, and Alex Lytchier. “Efficient context-aware lossy image    compression.” CVPR 2020, CLIC Workshop (2020).-   [5] Jan De Cock, and Anne Aaron. “The end of video coding?” The    Netflix Tech Blog (2018).-   [6] Nick Johnston, Elad Eban, Ariel Gordon, and Johannes Ballé.    “Computationally efficient neural image compression.” arXiv preprint    arXiv:1912.08771 (2019).-   [7] Lucas Theis, and George Toderici. “CLIC, workshop and challenge    on learned image compression.” CVPR 2020 (2020).-   [8] George Cybenko. “Mathematics of control.” Signals and Systems,    2, p. 337 (1989).-   [9] Moshe Leshno, Vladimir Ya Lin, Allan Pinkus, and Shimon    Schocken. “Multilayer feedforward networks with a nonpolynomial    activation function can approximate any function.” Neural networks,    6(6), pp. 861-867 (1993).

1. A computer implemented method of training a first neural network anda second neural network, the neural networks being for use in lossyimage or video compression, transmission and decoding, the methodincluding the steps of: (i) receiving an input training image; (ii)encoding the input training image using the first neural network, toproduce a latent representation; (iii) quantizing the latentrepresentation to produce a quantized latent; (iv) using the secondneural network to produce an output image from the quantized latent,wherein the output image is an approximation of the input image; (v)evaluating a loss function based on differences between the output imageand the input training image; (vi) evaluating a gradient of the lossfunction; (vii) back-propagating the gradient of the loss functionthrough the second neural network and through the first neural network,to update weights of the second neural network and of the first neuralnetwork; and (viii) repeating steps (i) to (vii) using a set of trainingimages, to produce a trained first neural network and a trained secondneural network; wherein the loss function comprises a rate loss term, adistortion loss term, and a mutual information loss term based on mutualinformation between the input training image and the output image. 2.The method of claim 1, wherein the mutual information loss term isdefined by one or more learned parameters.
 3. The method of claim 2,wherein step (vii) comprises back-propagating the gradient of the lossfunction through a third neural network, to update the weights of thethird neural network, the third neural network configured to producesaid one or more learned parameters.
 4. The method of claim 2,comprising training a third network to produce said one or more learnedparameters.
 5. The method of claim 1, wherein step (v) comprisesevaluating the mutual information loss term using a model of the outputimage comprising a combination of the input image with noise.
 6. Themethod of claim 5, wherein the noise comprises gaussian noise.
 7. Themethod of claim 1, wherein step (v) comprises evaluating the mutualinformation loss term using a mutual information estimator.
 8. Themethod of claim 7, wherein the mutual information estimator comprises afourth neural network.
 9. The method of claim 1, wherein the mutualinformation loss term is further based on mutual information betweeninput images and output images at different temporal positions in avideo stream.
 10. The method of claim 9, wherein the input images andthe output images at different temporal positions in the video streamcomprise images from consecutive frames of the video stream.
 11. Acomputer implemented method of training a first neural network and asecond neural network, the neural networks being for use in lossy imageor video compression, transmission and decoding, the method includingthe steps of: (i) receiving an input training image; (ii) encoding theinput training image using the first neural network, to produce a latentrepresentation distributed according to a first probabilitydistribution; (iii) quantizing the latent representation to produce aquantized latent; (iv) using the second neural network to produce anoutput image from the quantized latent, wherein the output image is anapproximation of the input image; (v) evaluating a loss function basedon differences between the output image and the input training image;(vi) evaluating a gradient of the loss function; (vii) back-propagatingthe gradient of the loss function through the second neural network andthrough the first neural network, to update weights of the second neuralnetwork and of the first neural network; and (viii) repeating steps (i)to (vii) using a set of training images, to produce a trained firstneural network and a trained second neural network; wherein the lossfunction comprises a rate loss term, a distortion loss term, and amutual information loss term based on mutual information between thelatent representation distributed according to the first probabilitydistribution and a target, second probability distribution.
 12. Themethod of claim 11, wherein the produced trained first neural network isconfigured to produce said latent representation according to saidtarget, second probability distribution after being trained.
 13. Themethod of claim 11, wherein the target, second probability distributioncomprises a gaussian or a Laplacian distribution.
 14. A data processingsystem, comprising at least one computer system configured to perform amethod for training a system of neural networks for lossy image or videocompression, transmission and decoding, the method of trainingcomprising the steps of: (i) receiving an input training image; (ii)encoding the input training image using the first neural network, toproduce a latent representation distributed according to a firstprobability distribution; (iii) quantizing the latent representation toproduce a quantized latent; (iv) using the second neural network toproduce an output image from the quantized latent, wherein the outputimage is an approximation of the input image; (v) evaluating a lossfunction based on differences between the output image and the inputtraining image; (vi) evaluating a gradient of the loss function; (vii)back-propagating the gradient of the loss function through the secondneural network and through the first neural network, to update weightsof the second neural network and of the first neural network; and (viii)repeating steps (i) to (vii) using a set of training images, to producea trained first neural network and a trained second neural network;wherein the loss function comprises a rate loss term, a distortion lossterm, and a mutual information loss term based on mutual informationbetween the latent representation distributed according to the firstprobability distribution and a target, second probability distribution.15. The data processing system of claim 14, wherein the produced trainedfirst neural network is configured to produce said latent representationaccording to said target, second probability distribution after beingtrained.
 16. The data processing system of claim 14, wherein the target,second probability distribution comprises a gaussian or a Laplaciandistribution.